# UNAVAILABLE: grpc: 服务器因 max_pings_without_data 发送了 GOAWAY

- **ID:** `grpc/grpc-max-pings-without-data`
- **领域:** grpc
- **类别:** protocol_error
- **验证级别:** ai_generated
- **修复率:** 78%

## 根因

服务器发送了 GOAWAY 帧，因为客户端在没有数据流的情况下发送了过多保活 ping。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| gRPC v1.38.0 | active | — | — |
| gRPC v1.49.0 | active | — | — |
| gRPC v1.58.0 | active | — | — |

## 解决方案

1. ```
   Adjust client keepalive settings: reduce grpc.keepalive_time_ms to a higher value (e.g., 300000 ms) and increase grpc.keepalive_timeout_ms. Example in C++: channel_args.SetInt(GRPC_ARG_KEEPALIVE_TIME_MS, 300000);
   ```
2. ```
   On the server, set the maximum allowed pings without data using environment variable GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA (e.g., 0 to disable the limit) or via channel args.
   ```
3. ```
   Ensure client sends data frames periodically (e.g., by sending health check RPCs) to avoid triggering the ping-only limit.
   ```

## 无效尝试

- **** — This may lead to undetected dead connections, causing other errors like 'stream removed'. (60% 失败率)
- **** — This can lead to resource exhaustion on the server if many clients ping aggressively. (50% 失败率)
- **** — The client will keep sending pings and get GOAWAY repeatedly, causing constant disconnections. (85% 失败率)
