Err*_*ter 3 java ssl go grpc grpc-java
我正在尝试用 Java 创建 grpc 服务客户端,其中服务器位于 goLang 中并使用 https 进行部署。我试图实现非安全连接[我不想通过证书]
public class testgrpc {
ManagedChannel channel ;
ServiceGrpc.ServiceBlockingStub blockingStub;
String host = "remotesecuredhost";
int port ="XXX";
@Test
public void testgrpc()
{
channel = ManagedChannelBuilder.forAddress(host,port).build();
blockingStub = ServiceGrpc.newBlockingStub(channel);
response = blockingStub.health(Empty.newBuilder().build());
}
}
Run Code Online (Sandbox Code Playgroud)
上面的代码给出了以下异常
io.grpc.StatusRuntimeException: UNAVAILABLE: io exception
at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:221)
at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:202)
at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:131)
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙处理客户端代码吗
就我而言,我终于找到了解决方案
Could not find TLS ALPN provider; no working netty-tcnative,
Conscrypt, or Jetty NPN/ALPN available
Run Code Online (Sandbox Code Playgroud)
为了解决这个问题,我设置了如下版本
grpc-netty - 1.20.x- ||| netty-handler-4.1.34.Final ||| netty-tcnative-boringssl-static 版本 2.0.22.Final 从这里得到了想法
channel = NettyChannelBuilder
.forAddress("host",port)
.sslContext(GrpcSslContexts.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build())
.build();
Run Code Online (Sandbox Code Playgroud)
channel = NettyChannelBuilder
.forAddress("host",port).usePlaintext()
.build();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5822 次 |
| 最近记录: |