Correct way to create connections and make gRPC calls

475 views
Skip to first unread message

16.shi...@gmail.com

unread,
Jun 9, 2016, 9:53:21 AM6/9/16
to grpc.io

I am using gRPC with ruby on both client and server side. I was managing the client connection in this way:

1. Create the connection once when application starts -> 
@SEARCH_CLIENT = Search::HouseSearchService::Stub.new('localhost:50052', :this_channel_is_insecure)

2. Use the client instance to make gRPC calls during runtime. 
@SEARCH_CLIENT.search(request)

The problem that I am facing in this scheme is that whenever I restart my service, the gRPC call returns a GRPC BadStatus 14

Is it okay to create the connection and make the call together everytime during runtime for each call? Or should I just put some error handling myself to re-connect in case I get an error?


Michael Lumish

unread,
Jul 12, 2016, 6:52:13 PM7/12/16
to 16.shi...@gmail.com, grpc.io
Actually, you don't need to do either of those. When the client loses the connection, it will automatically attempts to reconnect. Status code 14 is the UNAVAILABLE status (https://github.com/grpc/grpc/blob/master/include/grpc/impl/codegen/status.h#L144), which is transient. When you get that error, you should just retry the call with the same client (assuming that the server logic can handle retries).

--
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 post to this group, send email to grp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/b01383bd-030d-4ea9-a4f3-990203a5e07f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages