ClientStream hangs forever when server crashes/hung up

166 views
Skip to first unread message

Rainer Schoenberger

unread,
Sep 14, 2022, 8:36:19 AM9/14/22
to grpc.io
Hi,
I am having trouble recovering  on the client side when a streaming server hangs.
I am actually using the gRPC provided proto_reflection_descriptor_database.cc as client code.
It uses
stream_->Finish()
to destrtuct and determine if reflection calls succeeded.

However when remote side hangs up, the Finish() call on client side blocks forever (to simulate hanging/crashing server, press Ctrl+Z on the server to just stop scheduling it).

I tried the following workarounds:
- Use ClientContext to set a deadline. -> Does not work, as deadline affects whole stream liefetime (not a keep-alive), which we do not know.
- Before call to Finish() call TryCancel() on the ctx. This works, however it overwrites any RPC status, and all streams then end with CANCELLED state. No way to tell if RPC failed due to other reason (e.g. UNIMPLEMENTED)

Is there any way to call Finish() without blocking. e.g. something like tryFinish() to get any RPC errors, which already are known already? Or give a deadline after RPC has started?

Thanks for your help,
Rainer

Reply all
Reply to author
Forward
0 new messages