【发布时间】:2020-05-06 15:52:38
【问题描述】:
我正在用 Kotlin 编写一个应用程序来连接到 grpc 服务器并获取数据。
下面是我的代码 sn-p :
channel = ManagedChannelBuilder.forTarget("localhost:25001")
.usePlaintext()
.build()
stub = hello.HelloGrpc.newBlockingStub(channel)
我的 GRPC 服务器关闭,但我可以看到这两个变量的值如下:
for channel = channelManagedChannelOrphanWrapper{delegate=ManagedChannelImpl{logId=1, target=localhost:25001}}
for stub = channelhello.HelloGrpc$HelloBlockingStub@19b843ba
我很困惑,如何检查连接是否未激活。
目前,我在获取值时添加了 try catch 语句,这会引发错误
不可用:io 异常
只是想知道,有什么方法可以检查我的连接状态并尝试重新连接以断开连接。
【问题讨论】:
标签: java kotlin grpc grpc-java