# gRPC 错误：INTERNAL：HTTP/2 ping 超时

- **ID:** `api/grpc-error-internal-http2-ping-timeout`
- **领域:** api
- **类别:** protocol_error
- **错误码:** `INTERNAL`
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

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

## 版本兼容性

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

## 解决方案

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.
   ```

## 无效尝试

- **** — Keepalive is essential for detecting dead connections; disabling it can lead to stale connections. (50% 失败率)
- **** — The server may have a lower keepalive threshold, causing the server to close the connection first. (70% 失败率)
- **** — The issue is a configuration mismatch, not a code bug. (90% 失败率)
