gRPC keepalive Ruby

407 views
Skip to first unread message

jdw...@gmail.com

unread,
Jul 6, 2018, 2:54:57 PM7/6/18
to grpc.io
I have a Ruby server. I want to stream the same information to many clients. 

Clients call my server streamer, I add their Enum to a list.  

When I want to broadcast I go through the list of enums and push something into their queue.  This all works well.

When a client goes away however, I'm having trouble detecting that and removing them from my list.


My thought was to use keepalive, and hope that I would be able to detect that the _call's associated with the streams would be `cancelled?` once the server has disconnected them. 

Just for testing I have set keepalive quite short.

server_args = {
"grpc.keepalive_time_ms" => 4000,
"grpc.keepalive_timeout_ms" => 4000,
"grpc.keepalive_permit_without_calls" => 0,
"grpc.http2.min_time_between_pings_ms" => 4000,
"grpc.max_connection_age_ms" => 4000,
  "grpc.max_connection_age_grace_ms" => 2000,
"grpc.max_connection_idle_ms" => 4000
}
s = GRPC::RpcServer.new(pool_size: 1024,
max_waiting_requests: 1024,
server_args: server_args,
interceptors: interceptors)

Configured like this, I do see the client receive GO_AWAY but in the ruby server I'm not at all sure how to detect that these connections are kaput.

Any ideas / thoughts? 

-Jeff

jdw...@gmail.com

unread,
Jul 6, 2018, 2:59:01 PM7/6/18
to grpc.io
I have a java server and I found that I could 

} catch (StatusRuntimeException sre) {
if (sre.getStatus().getCode() == Status.Code.CANCELLED) {

But there's something about the way the ruby streaming enums works that is not throwing a similar error.

apo...@google.com

unread,
Aug 6, 2018, 6:15:07 PM8/6/18
to grpc.io
The way in that the server response stream is is sent with a "pull API" rather than "push API" indeed prevents e.g. detecting failed writes from the application's stream handler. Is is possible to continuously read from the "requests from client stream" enumerable on the server - that "requests enumerable" will terminate when (among other possible reasons) the call is cancelled.
Reply all
Reply to author
Forward
0 new messages