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





-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/3d079e96-0ad4-4efd-b0ee-e59e6498e80b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to