GRPC io.grpc.StatusRuntimeException:不可用:io 异常

问题描述 投票:0回答:1

代码模型看起来像

 Iterator iterator = grpc.invokeSomeRequest(requestData) //returns iterator
 while(iterator.hasNext()){
     //do some code.
 }

有时错误发生在

iterator.hasNext()
,并带有堆栈跟踪:

UNAVAILABLE: io exception               
io.grpc.StatusRuntimeException: UNAVAILABLE: io exception                                                                                                                                
     at io.grpc.Status.asRuntimeException(Status.java:533) 

grpc的版本是1.21.0

我发现这个问题最有可能出现在 grpc 上。我可能是错的。 解决此问题的最佳方法是什么?

grpc grpc-java
1个回答
0
投票

对我来说,当我使用时,这个问题就解决了

channelBuilder = NettyChannelBuilder.forAddress(host, port).usePlaintext().enableRetry().keepAliveTime(10,TimeUnit.SECONDS);

而不是

channelBuilder = NettyChannelBuilder.forAddress(host, port);
channelBuilder.negotiationType(NegotiationType.TLS).enableRetry().keepAliveTime(10,TimeUnit.SECONDS);
channelBuilder.sslContext(
              GrpcSslContexts.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build())
© www.soinside.com 2019 - 2024. All rights reserved.