How can I turn off HTTPS on gRPC server? Is there any option?
Despite it's an old question, I had to do this by myself recently and here is how I did it, based on the ASP.NET Core template from Visual Studio:
First you'll have to configure the kestrel webserver to use the HTTP2 protocol for HTTP (usually in Program.cs):
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.ConfigureKestrel(options =>
options.ConfigureEndpointDefaults(defaults =>
defaults.Protocols = HttpProtocols.Http2));
webBuilder.UseStartup<Startup>();
});
Now the server should be able to handle all calls, regardless of using HTTP or HTTPS.
After you did that, you just have to tell the client to allow using HTTP2 without HTTPS before you make your first call to the gRPC server:
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
var client = new GrpcTest.GrpcTestClient(GrpcChannel.ForAddress("http://localhost:5000"));
Sources:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With