Browse Source

Shutdown before re-opening

pull/2436/head
Volodymyr Babak 6 years ago
parent
commit
c677b1bdc3
  1. 11
      common/edge-api/src/main/java/org/thingsboard/edge/rpc/EdgeGrpcClient.java

11
common/edge-api/src/main/java/org/thingsboard/edge/rpc/EdgeGrpcClient.java

@ -79,6 +79,7 @@ public class EdgeGrpcClient implements EdgeRpcClient {
throw new RuntimeException(e);
}
}
gracefulShutdown();
channel = builder.build();
EdgeRpcServiceGrpc.EdgeRpcServiceStub stub = EdgeRpcServiceGrpc.newStub(channel);
log.info("[{}] Sending a connect request to the TB!", edgeKey);
@ -89,6 +90,16 @@ public class EdgeGrpcClient implements EdgeRpcClient {
.build());
}
private void gracefulShutdown() {
try {
if (channel != null) {
channel.shutdown().awaitTermination(timeoutSecs, TimeUnit.SECONDS);
}
} catch (InterruptedException e) {
log.debug("Error during shutdown of the previous channel", e);
}
}
@Override
public void disconnect() throws InterruptedException {
inputStream.onCompleted();

Loading…
Cancel
Save