Message send policy with not responsive client
Closed this issue · 5 comments
Hi. Thanks for a great project.
I have a project with bidirectional streaming, and I don’t understand what happens when server sends messages but client never calls recv? As I see now, server is not blocked in this case, but shouldn’t it cause a memory increasing usage on client or server?
Hi. HTTP/2 has a flow control mechanism which prevents sending unlimited amounts of data. You can see default values here: https://grpclib.readthedocs.io/en/latest/config.html, you can also set custom window sizes, but I don't see this as a solution to your problem.
If client never calls recv_message
, client don't send acks to the server (WINDOW_UPDATE
frame) and current window keeps decreasing. When window becomes zero server stops sending data, send_message
on the server blocks and waits until client acks already sent data.
You can implement your own unresponsive client detection mechanism. I don't see how this can be implemented in a library.
Thanks for the answer. I don’t have such deep knowledge in grpc and http2. I’ll try to decrease window size and keep tracking the blocking of message sending
I have one more question - does this library has any alternative of isReady from Java grpc https://grpc.github.io/grpc-java/javadoc/io/grpc/stub/CallStreamObserver.html#isReady--
does this library has any alternative of isReady from Java grpc
Probably not, there are no public API to tell when server is ready to send more data, you just send and wait, flow control is automatic and there are no buffering on the sending side.
Ok, I understand. Thanks