grcp通过spring-boot在etcd中发布时失败



我正在使用springbok示例运行一个简单的etcd连接。我在春季启动日志和服务器日志中都不断收到一个关于grcp的错误。我该怎么解决这个问题?

@Scheduled(fixedRate = 5000)
public void test() throws EtcdException, ExecutionException, InterruptedException {
// create client
Client client = Client.builder().endpoints("http://localhost:2379").build();
KV kvClient = client.getKVClient();
ByteSequence key = ByteSequence.fromBytes("test_key".getBytes());
ByteSequence val = ByteSequence.fromBytes("test_val".getBytes());
// put the key-value
kvClient.put(key, val);
// get the CompletableFuture
CompletableFuture<GetResponse> getFuture = kvClient.get(key);
// get the value from CompletableFuture
GetResponse response = getFuture.get();
System.out.println(response.toString());
}

错误

.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [na:1.8.0_131]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_131]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_131]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_131]
Caused by: java.util.concurrent.ExecutionException: io.grpc.StatusRuntimeException: INTERNAL: Connection closed with unknown cause
at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:476) ~[guava-19.0.jar:na]
at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:455) ~[guava-19.0.jar:na]
at com.coreos.jetcd.internal.impl.Util.lambda$toCompletableFutureWithRetry$1(Util.java:125) ~[jetcd-core-0.0.1.jar:na]
... 3 common frames omitted
Caused by: io.grpc.StatusRuntimeException: INTERNAL: Connection closed with unknown cause
at io.grpc.Status.asRuntimeException(Status.java:526) ~[grpc-core-1.5.0.jar:1.5.0]
at io.grpc.stub.ClientCalls$UnaryStreamToFuture.onClose(ClientCalls.java:427) ~[grpc-stub-1.5.0.jar:1.5.0]
at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:41) ~[grpc-core-1.5.0.jar:1.5.0]
at com.coreos.jetcd.internal.impl.ClientConnectionManager$AuthTokenInterceptor$1$1.onClose(ClientConnectionManager.java:267) ~[jetcd-core-0.0.1.jar:na]
at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:419) ~[grpc-core-1.5.0.jar:1.5.0]
at io.grpc.internal.ClientCallImpl.access$100(ClientCallImpl.java:60) ~[grpc-core-1.5.0.jar:1.5.0]
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:493) ~[grpc-core-1.5.0.jar:1.5.0]
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$500(ClientCallImpl.java:422) ~[grpc-core-1.5.0.jar:1.5.0]
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:525) ~[grpc-core-1.5.0.jar:1.5.0]
at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) ~[grpc-core-1.5.0.jar:1.5.0]
at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:102) ~[grpc-core-1.5.0.jar:1.5.0]
... 3 common frames omitted

在ETCD服务器

WARNING: 2020/04/16 00:23:15 grpc: Server.processUnaryRPC failed to write status: connection error: desc = "transport is closing"

尝试设置保活属性,但不起作用

grpc.client.GLOBAL.keep-alive-time=5000

所以事实证明grcp版本是原因,我使用的是verion1.5.0,但当我转到版本1.9.0时,这个问题为我解决了。

最新更新