Hi All,
I am using grpc java with serverside streaming.In the grpc server side streaming service I am doing streaming such as below to detect stream cancellations due to network errors.
while(true) {
if(Context.current().isCancelled()) {
responseObserver.onNext(response)
} else break;
The issue is when I disconnect the client still onNext invokes around 100 times before network failure is detected by Context.current().isCancelled().
To prevent this I did as below.
while(true) {
Thread.sleep(500)
if(Context.current().isCancelled()) {
responseObserver.onNext(response)
} else break;
Now it seems isCancelled is detected before onNext is called when network between client and server is disrupted.This implies cancel=true is updated by a separate thread apart from main thread??
Is there any better way of doing this using GRPC Java?
Thanks
Isuru