Hello,
I have a use case to have a stream continuously opened between server and the client. The server uses the stream to push data to the client. However, we have certain scenarios wherein we might need to terminate the stream. I tried using the following wherein I could find that the client gets closed but the server still continues to push the data.
CancellableContext withCancellation = Context.current().withCancellation();
withCancellation.run(new Runnable() {
@Override
public void run() {
nonblockingStub.listFeatures(request, responseObserver);
}
});
Thread.sleep(15000);
withCancellation.cancel(null);
Thread.sleep(15000);
Also would like to know if there is an option for an idle timeout for a stream wherein if there are no traffic on the stream for a specified duration the stream gets terminated something similar to keepAlive for ManagedChannelBuilder.
Note: We are having a server side streaming only.
Waiting eagerly for your replies. :)
Regards
Suv