Improved disconnect process - try 5 times before force close session
This commit is contained in:
parent
770d3f91f2
commit
c5f5acdba1
@ -154,10 +154,30 @@ public class EdgeGrpcClient implements EdgeRpcClient {
|
|||||||
if (!onError) {
|
if (!onError) {
|
||||||
try {
|
try {
|
||||||
inputStream.onCompleted();
|
inputStream.onCompleted();
|
||||||
} catch (Exception ignored) {}
|
} catch (Exception e) {
|
||||||
|
log.error("Exception during onCompleted", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (channel != null) {
|
if (channel != null) {
|
||||||
channel.shutdown().awaitTermination(timeoutSecs, TimeUnit.SECONDS);
|
channel.shutdown();
|
||||||
|
int attempt = 0;
|
||||||
|
do {
|
||||||
|
try {
|
||||||
|
channel.awaitTermination(timeoutSecs, TimeUnit.SECONDS);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Channel await termination was interrupted", e);
|
||||||
|
}
|
||||||
|
if (attempt > 5) {
|
||||||
|
log.warn("We had reached maximum of termination attempts. Force closing channel");
|
||||||
|
try {
|
||||||
|
channel.shutdownNow();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Exception during shutdownNow", e);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
attempt++;
|
||||||
|
} while (!channel.isTerminated());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user