-
-
Save fzankl/885e6b0f54b6469b0e38456074d88812 to your computer and use it in GitHub Desktop.
gRPC request in .NET Core
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// .NET Core 3.x | |
// To use gRPC without TLS following switch must be set before creating the GrpcChannel/HttpClient. | |
// AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); | |
var options = new GrpcChannelOptions(); | |
var channel = GrpcChannel.ForAddress("https://localhost:5001", options); | |
var client = new FooService.FooServiceClient(channel); | |
// Asynchronous unary RPC | |
var foosRequest = new FooRequest { Message = "Sample request" }; | |
var fooResponse = await client.GetFooAsync(foosRequest); | |
Console.WriteLine($"\t{fooResponse.Message}"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment