go network_error ai_generated true

rpc error: code = Unavailable desc = closing transport due to: connection error: desc = "error reading from server: EOF", received prior goaway: code: ENHANCE_YOUR_CALM, debug data: "too_many_pings"

ID: go/grpc-keepalive-too-aggressive

Also available as: JSON · Markdown · 中文
80%Fix Rate
87%Confidence
0Evidence
2024-10-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.50+ active

Root Cause

The client sends keepalive pings more frequently than the server's MinTime permits, causing the server to send GOAWAY with ENHANCE_YOUR_CALM.

generic

中文

客户端发送 keepalive ping 的频率超过服务端 MinTime 限制,服务端发送 GOAWAY 并附 ENHANCE_YOUR_CALM。

Workarounds

  1. 90% success
    Set client keepalive to at least the server's MinTime (default 5 min):
    conn, _ := grpc.NewClient(addr,
      grpc.WithKeepaliveParams(keepalive.ClientParameters{
        Time: 5*time.Minute, Timeout: 20*time.Second, PermitWithoutStream: false,
      }))
  2. 85% success
    On the server, lower the enforcement threshold:
    srv := grpc.NewServer(grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{
      MinTime: 10*time.Second, PermitWithoutStream: true,
    }))

Dead Ends

Common approaches that don't work:

  1. 60% fail

    Loses detection of dead connections through idle NAT/LB timeouts, causing silent hangs.

  2. 90% fail

    MaxConnectionAge is a server option; the client's setting is ignored.