[C++] How to detect client disconnect on synchronous streaming server

212 views
Skip to first unread message

banshe...@googlemail.com

unread,
Jul 5, 2018, 6:45:53 AM7/5/18
to grpc.io
Hi,

I'm using the synchronous server API to stream large fields of binary data from server to client. Once I pull out the ethernet cable on my client it will correctly fail with an according grpc::Status, however the server side will never be notified about the client disconnect and forever block in grpc::internal::WriterInterface<>::Write. Since we currently disallow multiple clients to simultaneously access the server, our server is at this point deadlocked and virtually inacessible. Is there a way to get out of this situation?
Message has been deleted

banshe...@googlemail.com

unread,
Jul 18, 2018, 6:38:22 AM7/18/18
to grpc.io
Having digged further into this, it appears to be a linux-specific problem. I don't have this issue with a Windows server. And the message size also doesn't matter. The problem is reproducible with empty messages, too.

juanl...@google.com

unread,
Jul 18, 2018, 1:35:58 PM7/18/18
to grpc.io
Hi, could you file an issue on https://github.com/grpc/grpc/issues with the (minimal, desirably) reproducing step?

BTW, if this issues happens even when the messages are empty, I suppose you are keeping sending the messages?

banshe...@googlemail.com

unread,
Jul 18, 2018, 1:47:51 PM7/18/18
to grpc.io
In principle, yes. I also already compiled a minimal reproducing example. However I found various issues which might be related, i.e. https://github.com/grpc/grpc/issues/15889 or https://github.com/grpc/grpc/issues/14779 .
Concerning the second part of the question: I make an RPC which returns a stream of empty messages and the server just keeps sending them in an infinite loop, yes. The interesting thing is that the server correctly ends the stream if I shutdown the client gracefully. Only if I deactivate my network adapter or pull the cable on the client is when I can observe the above-mentioned effect.

Yang Gao

unread,
Aug 6, 2018, 7:04:12 PM8/6/18
to grpc.io
It sounds like the problem is similar to #15889 as you mentioned. We should continue the discussion in the issue.

banshe...@googlemail.com

unread,
Aug 7, 2018, 6:11:09 AM8/7/18
to grpc.io
Yes, the 1.14 update in combination with these channel args on the server side fixed my issue:

    builder.AddChannelArgument(GRPC_ARG_KEEPALIVE_TIME_MS, 1000);
    builder.AddChannelArgument(GRPC_ARG_KEEPALIVE_TIMEOUT_MS, 1000);
    builder.AddChannelArgument(GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS, 500);
    builder.AddChannelArgument(GRPC_ARG_HTTP2_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS, 1000);
Reply all
Reply to author
Forward
0 new messages