Detect stream closed from client?

50 views
Skip to first unread message

Natalie Serrino

unread,
Sep 18, 2020, 12:02:47 AM9/18/20
to grpc.io
Hi all,

I have a GRPC streaming API in C++ that streams from the client to the server.

rpc TransferResultChunk(stream TransferResultChunkRequest) returns (TransferResultChunkResponse) {}

The server may cancel the context and close the stream at any time. Is there a way for the client to detect that this has occurred without writing to the stream? I was thinking there would be something like IsCancelled() like grpc::ServerContext has in grpc::ClientContext, but it doesn't seem to exist.

It does seem to be possible in Golang, so I thought I would see if I was missing something on the C++ side.

Thanks a lot,
Natalie

veb...@google.com

unread,
May 27, 2022, 1:47:30 PM5/27/22
to grpc.io
No, you need to call write to notice if it's closed.
Reply all
Reply to author
Forward
0 new messages