You can turn on keep alives on the channel / server builder, but that's
about the best you can do. The problem is that a broken connection just
means silence. You can't tell the difference between the packets taking a
long time, and the the packets not arriving. Keep-alives let you check the
connection is still active, and close it after a time out (like 10s).
On Tuesday, April 30, 2019 at 9:10:22 AM UTC-7, Isuru Samaraweera wrote:
>
> 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/4dc517ad-195c-420f-9f7a-4e73aa78b659%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.