Client wait for RPC to finish when RPC is cancelled

55 views
Skip to first unread message

Robert Bielik

unread,
Aug 22, 2018, 9:06:05 AM8/22/18
to grpc.io
I have a situation where I cancel a streaming RPC, upon which the client will return grpc::CANCELLED on reader->Finish(). However it does this directly because of the TryCancel on the client context, not because of the controller return of the RPC.

Since my RPC using an exclusive resource, only one client can be connected at time. Because of the early return on TryCancel, I can call the RPC again but it hasn't finished, so I get a grpc::RESOURCE_EXHAUSTED.

I would like to be able to cancel an RPC, then wait until the RPC has "acknowledged" the cancellation, preferably by default gRPC methods.

Regards
/Robert

yas...@google.com

unread,
Sep 4, 2018, 2:27:52 PM9/4/18
to grpc.io
gRPC cancellation does not provide such a guarantee. I can't think of a clean way to do what you need, but some solutions would be 
1) keep retrying till it works. (The servers should read the cancellation at some point.)
2) Expose RPC methods that tell you whether the resource is available.. (similar to lock, trylock, unlock)
Reply all
Reply to author
Forward
0 new messages