Skip to content

Instantly share code, notes, and snippets.

@fzankl
Created January 24, 2021 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fzankl/885e6b0f54b6469b0e38456074d88812 to your computer and use it in GitHub Desktop.
Save fzankl/885e6b0f54b6469b0e38456074d88812 to your computer and use it in GitHub Desktop.
gRPC request in .NET Core
// .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