go
network_error
ai_generated
partial
rpc 错误:code = Unavailable desc = 从服务器读取错误:EOF
rpc error: code = Unavailable desc = error reading from server: EOF
ID: go/grpc-connection-closing-transport
80%修复率
87%置信度
0证据数
2024-07-21首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| grpc-go 1.58+ | active | — | — | — |
根因分析
服务器在流传输中途关闭了 HTTP/2 连接。通常是服务器进程退出、重启,或代理/负载均衡器断开了连接。
English
The server closed the HTTP/2 connection mid-stream. Typically the server process exited, was restarted, or a proxy/load balancer dropped the connection.
解决方案
-
85% 成功率
Enable client keepalive to detect dead connections quickly: conn, err := grpc.NewClient(addr, grpc.WithKeepaliveParams(keepalive.ClientParameters{ Time: 10 * time.Second, Timeout: 3 * time.Second, PermitWithoutStream: true, }), ) -
82% 成功率
Add a retry policy for UNAVAILABLE and inspect server logs for crashes: // configure retryableStatusCodes: ["UNAVAILABLE"] in the service config, then check server OOM/panic logs.
无效尝试
常见但无效的做法:
-
70% 失败
The error originates at the transport layer from the server side closing the connection; the client handler is not at fault.
-
80% 失败
Disabling keepalive does not prevent the server from closing; it actually makes stale connections harder to detect.