无法连接到此链接中提到的迎宾 grpc 服务 - https://docs.microsoft.com/en-us/aspnet/core/tutorials/grpc/grpc-start?view=aspnetcore-3.0 从迎宾客户端是使用 grpc.core 库(Grpc.Core.2.24.0和Grpc.Core.Api.2.24.0)从 .net 框架应用程序编写。
下面是我的客户端代码。它适用于非 SSL,但不适用于 SSL
具有非 SSL 的客户端代码(这有效)
var channel = new Channel("localhost:5000", ChannelCredentials.Insecure);
var client = new Greeter.GreeterClient(channel);
var reply = await client.SayHelloAsync(new HelloRequest { Name = "GreeterClient" });
channel.ShutdownAsync().Wait();
Run Code Online (Sandbox Code Playgroud)
带有 SSL 的客户端代码(无法连接)
SslCredentials secureChannel = new SslCredentials();
var channel = new Channel("localhost", 5001, secureChannel);
var client = new Greeter.GreeterClient(channel);
var reply = await client.SayHelloAsync(new HelloRequest { Name = "GreeterClient" });
channel.ShutdownAsync().Wait();
Run Code Online (Sandbox Code Playgroud)
我使用 SSL 遇到的错误是:
Grpc.Core.RpcException: 'Status(StatusCode=Unavailable, …