GRPC re-connection with IP change in client side

395 views
Skip to first unread message

Surajit Sinha

unread,
Mar 11, 2021, 5:16:46 AM3/11/21
to grpc.io

Hi All,

I have a GRPC server client model. The client wait on read indefinitely. In case where the server is stopped, the client gets notified and I retry connection again until success. This works fine.

In another case when the router the client is connected to goes down, the client reconnect to the next available router and try a GRPC reconnection, but the message never reaches the server.

I tried applying a deadline and every time deadline exceeded do a re-connection. The re-connection works as long the router is same and client have same ip, in case the router is changed and client get a new ip the message again does not reach the server.

What is the right method of a GRPC reconnection with server in case of a client ip change ?

it appears the read returns approximately after 20 minutes, till that time it doesn't let any new packet reach the server 


Thanks and Best Regards,

Surajit 

Emmanuel Delmas

unread,
Mar 15, 2021, 7:27:42 AM3/15/21
to grpc.io
Hi Surajit

I've learned that you cannot trigger directly a refresh on DNS resolution. But refresh are triggered each time a connection is closed.
It means that having a channel with multiple connections that are stopped regularly will provide you an up to date DNS resolution.
To stop regularly your connections from the server side, use the keepalive parameters ("max_connection_age_ms").
A channel creates a connection for all received IP from DNS resolution. Use http2 load balancing to use all of them.
To detect stucked gRPC connections from the client side, add keepalive timeout parameter ("grpc.keepalive_time_ms", "grpc.keepalive_timeout_ms").

Hope it will help you

Emmanuel Delmas

suraji...@snehix.com

unread,
Mar 15, 2021, 10:26:40 AM3/15/21
to Emmanuel Delmas, grpc.io

Hi Emmanuel,

Thanks for the reply.  : )

I too have arrived to the same solution from the client side, and for now I do not see the problem anymore. Below changes I did in client side

 

/* https://github.com/grpc/proposal/blob/master/A18-tcp-user-timeout.md */

 

        ChannelArguments args;

        args.SetInt(GRPC_ARG_KEEPALIVE_TIME_MS,10000);

        args.SetInt(GRPC_ARG_KEEPALIVE_TIMEOUT_MS,5000);

 

        v.push_back(MessagingImplClient(

                        grpc::CreateCustomChannel(

                                address,

                                grpc::InsecureChannelCredentials(),

                                args

                                )

        ));

 

From the server side, I will try use the “max_connection_age_ms”.

 

Thanks and Best Regards,

Surajit

--
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/5dfc9895-b39c-468d-b074-f041db5c0a90n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages