INTERNAL api protocol_error ai_generated true

gRPC 错误:INTERNAL:HTTP/2 ping 超时

gRPC error: INTERNAL: HTTP/2 ping timeout

ID: api/grpc-error-internal-http2-ping-timeout

其他格式: JSON · Markdown 中文 · English
85%修复率
86%置信度
1证据数
2024-05-20首次发现

版本兼容性

版本状态引入弃用备注
gRPC Go 1.62 active
gRPC Python 1.60 active
Envoy 1.28 active
gRPC-Web 1.50 active
Istio 1.20 active

根因分析

gRPC 客户端或服务器未能在 keepalive 超时时间内收到 PING 确认,导致连接关闭。

English

The gRPC client or server failed to receive a PING acknowledgment within the keepalive timeout period, causing the connection to be closed.

generic

官方文档

https://grpc.io/docs/guides/keepalive/

解决方案

  1. Set consistent keepalive parameters on both client and server. In gRPC Go, use grpc.WithKeepaliveParams(keepalive.ClientParameters{Time: 10 * time.Second, Timeout: 5 * time.Second, PermitWithoutStream: true}). On the server, set keepalive.EnforcementPolicy{MinTime: 10 * time.Second, PermitWithoutStream: true}.
  2. If using Envoy, add 'http2_protocol_options: { connection_keepalive: { interval: 10s, timeout: 5s } }' to the cluster configuration.
  3. Check for network intermediaries (e.g., firewalls, load balancers) that may drop HTTP/2 PING frames. Configure them to allow HTTP/2 keepalive packets.

无效尝试

常见但无效的做法:

  1. 50% 失败

    Keepalive is essential for detecting dead connections; disabling it can lead to stale connections.

  2. 70% 失败

    The server may have a lower keepalive threshold, causing the server to close the connection first.

  3. 90% 失败

    The issue is a configuration mismatch, not a code bug.