Nilotpal
Nilotpal

Reputation: 3578

Error : too_many_pings error in gRPC service calls

What is too_many_pings error in grpc?

  1. Are these error only from server to client side or there are use cases where client can also send the same to server(I know its weird! but in case any use case exist!!)

  2. Does the server disconnects the channel after this error or still ready to receive request ?

How to avoid it? Is it a good idea to avoid it?

Thanks in advance, Nilotpal

Upvotes: 1

Views: 4272

Answers (2)

Nilotpal
Nilotpal

Reputation: 3578

This is to safeguard from grpc clients streams who stay connected even when there is no data movements in the stream. When the stream is active and no data movement, the client keeps on pinging server to know whether its alive!! Thes continuous ping requests are basically abusive from servers point-of-view. When such a stale connection is detected, server sends this error and discontinues with client and the client is not able to further communicate or send any request.

But certainly some use cases arise when client want to stay connected for hours even if there is no incoming requests. Basically a stale stream.

In those cases both client and server has to configure themselves to allow such HTTP/2 Pings!!

Server Enforcement

**Servers will have two settings for enforcement:**

PERMIT_KEEPALIVE_TIME, defaulting to 5 minutes
PERMIT_KEEPALIVE_WITHOUT_CALLS to true

**The client options can be specified** via ManagedChannelBuilder.keepAliveTime(), keepAliveTimeout(), and keepAliveWithoutCalls()

Detailed documentation can be found in post above, @San P's github link.

Upvotes: 0

San P
San P

Reputation: 519

See this https://github.com/grpc/proposal/blob/master/A8-client-side-keepalive.md#server-enforcement for more information.

  1. Yes, only from server to client. No use-case for client-to-server.

  2. Yes, as per https://github.com/grpc/proposal/blob/master/A8-client-side-keepalive.md#server-enforcement.

I think it's a good idea to avoid clients sending too many pings. In Java you can use ManagedChannelBuilder.keepAliveTime().

Upvotes: 1

Related Questions