go network_error ai_generated true

rpc error: code = Unavailable desc = connection error: desc = "transport: http2Client.notifyError got notified that the client transport was broken EOF"

ID: go/grpc-keepalive-too-frequent

Also available as: JSON · Markdown · 中文
80%Fix Rate
86%Confidence
0Evidence
2024-09-12First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
google.golang.org/grpc v1.55+ active — — —

Root Cause

Client keepalive pings are more frequent than the server's enforcement policy allows; the server sends GOAWAY and closes the connection.

generic

中文

客户端 keepalive ping 频率高于服务器强制策略允许的值;服务器发送 GOAWAY 并关闭连接。

Workarounds

  1. 92% success
    kp := keepalive.ClientParameters{
        Time:                5 * time.Minute,
        Timeout:             20 * time.Second,
        PermitWithoutStream: false,
    }
    conn, _ := grpc.NewClient(addr,
        grpc.WithKeepaliveParams(kp),
        grpc.WithTransportCredentials(insecure.NewCredentials()),
    )
  2. 88% success
    s := grpc.NewServer(grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{
        MinTime:             10 * time.Second,
        PermitWithoutStream: false,
    }))

Dead Ends

Common approaches that don't work:

  1. 70% fail

    Idle connections behind NAT/LB get silently dropped; subsequent RPCs fail with Unavailable.

  2. 95% fail

    Makes the problem worse — server enforces MinTime and closes the connection faster.