Skip to content

Latest commit

 

History

History
46 lines (34 loc) · 1.74 KB

keepalive.md

File metadata and controls

46 lines (34 loc) · 1.74 KB

Keepalive

gRPC sends http2 pings on the transport to detect if the connection is down. If the ping is not acknowledged by the other side within a certain period, the connection will be close. Note that pings are only necessary when there's no activity on the connection.

For how to configure keepalive, see https://godoc.org/google.golang.org/grpc/keepalive for the options.

What should I set?

It should be sufficient for most users to set client parameters as a dial option.

What will happen?

(The behavior described here is specific for gRPC-go, it might be slightly different in other languages.)

When there's no activity on a connection (note that an ongoing stream results in no activity when there's no message being sent), after Time, a ping will be sent by the client and the server will send a ping ack when it gets the ping. Client will wait for Timeout, and check if there's any activity on the connection during this period (a ping ack is an activity).

What about server side?

Server has similar Time and Timeout settings as client. Server can also configure connection max-age. See server parameters for details.

Enforcement policy

Enforcement policy is a special setting on server side to protect server from malicious or misbehaving clients.

Server sends GOAWAY with ENHANCE_YOUR_CALM and close the connection when bad behaviors are detected:

  • Client sends too frequent pings
  • Client sends pings when there's no stream and this is disallowed by server config