Close a bidirectional RPC stream in gRPC java

87 views
Skip to first unread message

Steven Hu

unread,
Jul 11, 2024, 12:09:14 AM7/11/24
to grpc.io
Hello gRPC community,

I noticed some asymmetry for bidirectional RPC stream closure between RPC client and RPC server.
  • If RPC stream client sends onCompleted(),  server end will receive onCompleted().  It closes the stream on client->server direction. server could still send message to client.
  • If RPC stream server sends onCompleted(),  client end will receive onCompleted(). However,  client end could no longer send messages to server. It seems that the entire stream has been closed. 
Is this expected? 

Larry Safran

unread,
Jul 11, 2024, 7:23:52 PM7/11/24
to Steven Hu, grpc.io
Yes, this is the expected behavior.  When the server sends the completion it then forgets about the RPC, while the client side has a more ownership relationship so keeps track of the RPC until it is fully closed.

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/4c4123fa-2d31-48ef-9417-beb42c3a9adbn%40googlegroups.com.

Steven Hu

unread,
Jul 12, 2024, 2:43:05 AM7/12/24
to grpc.io
Thanks for replay Larry! 

Is this documented somewhere? Curious what's the reason behind this design. From HTTP/2 perspective, both ends of a stream should be equal.

Also I noticed that for onError()
  • If RPC stream client sends onError(), both RPC stream client and RPC stream server will receive onError()
  • If RPC stream server sends onError(), only RPC stream client will received onError()
The asymmetric design is kind of hard to resonate.

Reply all
Reply to author
Forward
0 new messages