In server-side streaming, how does an ungraceful disconnection by a client get communicated back to the server?
If, for example, I have an application-level ping rpc, an then I unplug a network cable, after a few unsuccessful pings, the ServerCallStreamObserver will report the error. Without those pings, I am not receiving a notification. Using a NettyServerBuilder with 10s keepAlive and 500ms keepAliveTimeout, and code similar to this:
Context oldCurrent = Context.current();
Context previous = oldCurrent.attach();
Context.current().addListener(context -> log.error("Cancel received!"), executorService);
try {
while (!shutdown && !Thread.interrupted()) {
next = queue.poll();
if (next == null) {
log.debug("Queue is empty, waiting before next poll()");
Thread.sleep(1000);
// if sending an empty message here, the cancellation will be picked up quickly
//serverCallStreamObserver.onNext(PING);
} else {
serverCallStreamObserver.onNext(next);
}
}
} (catch and finally clauses snipped)
listeners attached to any of the above contexts never fire; what might I be missing in order to notify the application of a broken connection?