grpc
network_error
ai_generated
true
UNAVAILABLE: grpc: 流空闲超时
UNAVAILABLE: grpc: stream idle timeout reached
ID: grpc/stream-idle-timeout
78%修复率
84%置信度
1证据数
2023-11-12首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| gRPC Go 1.50+ | active | — | — | — |
| gRPC Python 1.50+ | active | — | — | — |
| Nginx gRPC proxy 1.25+ | active | — | — | — |
根因分析
流式RPC长时间不活动(没有发送或接收数据),由于空闲超时配置,服务器或客户端关闭了流。
English
A streaming RPC has been inactive for too long (no data sent or received) and the server or client closes the stream due to idle timeout configuration.
官方文档
https://grpc.io/docs/guides/keepalive/解决方案
-
Send periodic keepalive pings from client. In Go: grpc.WithKeepaliveParams(keepalive.ClientParameters{Time: 30 * time.Second, Timeout: 10 * time.Second}). Set server: keepalive.ServerParameters{MaxConnectionIdle: 5 * time.Minute} -
Use bidirectional streaming with periodic heartbeat messages. In Python: every 10 seconds send a small protobuf message (e.g., Empty) from client and have server echo it back.
无效尝试
常见但无效的做法:
-
Setting keepalive time to 0 (disable)
40% 失败
May cause connections to be dropped by network middleboxes that expect periodic traffic.
-
Increasing timeout on server only
35% 失败
Client may still have its own idle timeout that triggers first.