grpc protocol_error ai_generated true

UNAVAILABLE: grpc: 收到服务器GOAWAY,原因是ping过多

UNAVAILABLE: grpc: received goaway from server due to too_many_pings

ID: grpc/too-many-pings

其他格式: JSON · Markdown 中文 · English
85%修复率
88%置信度
1证据数
2023-06-15首次发现

版本兼容性

版本状态引入弃用备注
gRPC C++ 1.50+ active
gRPC Go 1.50+ active
Envoy 1.25+ active
Istio 1.18+ active

根因分析

客户端发送ping的频率过高,超过了服务器的max_pings_without_data或min_time_between_pings设置,导致服务器发送GOAWAY并关闭连接。

English

Client sends pings too frequently, exceeding server's max_pings_without_data or min_time_between_pings settings, causing server to send GOAWAY and close the connection.

generic

官方文档

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

解决方案

  1. Set client-side keepalive parameters: keepalive_time=30s, keepalive_timeout=10s, and min_time_between_pings=5s. In Go: grpc.WithKeepaliveParams(keepalive.ClientParameters{Time: 30 * time.Second, Timeout: 10 * time.Second, MinTimeBetweenPings: 5 * time.Second})
  2. Configure server-side max_pings_without_data to a higher value (e.g., 5) or increase min_time_between_pings (e.g., 10s). In C++ server builder: builder.AddChannelArgument(GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS, 10000);

无效尝试

常见但无效的做法:

  1. Increasing keepalive time without adjusting ping interval 40% 失败

    The issue is not the keepalive time but the ping frequency; increasing keepalive time alone may not reduce ping rate if min_time_between_pings is violated.

  2. Disabling keepalive entirely 30% 失败

    Disabling keepalive can cause long-lived connections to be dropped by middleboxes (e.g., NAT, firewalls) that expect periodic traffic.