排名
6
文章
6
粉丝
16
评论
8
{{item.articleTitle}}
{{item.blogName}} : {{item.content}}
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2024TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:50010702506256
欢迎加群交流技术
原
启动grpc报错:HTTP/2 over TLS is not supported on Windows 7
分类:
net core
.net core grpc报错:NotSupportedException: HTTP/2 over TLS is not supported on Windows 7 due to missing ALPN support
是因为win7不支持TLS的原因
解决方法:在Program.cs中配置不包含 TLS 的 HTTP/2 终结点即可
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { //配置不包含TLS的HTTP/2终结点 webBuilder.ConfigureKestrel(options => { options.ListenLocalhost(50001, a => a.Protocols = Microsoft.AspNetCore.Server.Kestrel.Core.HttpProtocols.Http2); }); webBuilder.UseStartup<Startup>(); });
主要是这句话 Protocols = HttpProtocols.Http2
让kestrel支持无 tls http/2
调用的时候端口要换成50001,还要设置允许不安全的HTTP2支持
public async void CallgRPC() { //设置允许不安全的HTTP2支持 AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); var channel = GrpcChannel.ForAddress("http://localhost:50001"); var client = new Greeter.GreeterClient(channel); var reply = await client.SayHelloAsync(new HelloRequest { Name = "GrpcClient" }); Console.WriteLine(reply.Message); Console.WriteLine("Greeting: " + reply.Message); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }
欢迎加群讨论技术,群:677373950(满了,可以加,但通过不了),2群:656732739
评价