go
network_error
ai_generated
true
rpc 错误:code = Unavailable,desc = 传输正在关闭
rpc error: code = Unavailable desc = transport is closing
ID: go/grpc-code-unavailable-transport-closing
80%修复率
89%置信度
0证据数
2024-08-11首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| google.golang.org/grpc 1.55+ | active | — | — | — |
根因分析
底层 HTTP/2 传输在 RPC 中途被拆除(服务端重启、空闲超时,或负载均衡器发送 GOAWAY 帧)。
English
The underlying HTTP/2 transport was torn down mid-RPC (server restart, idle timeout, or GOAWAY frame from load balancer).
解决方案
-
92% 成功率
Enable client-side retry policy via service config: conn, _ := grpc.NewClient(addr, grpc.WithDefaultServiceConfig(`{"methodConfig":[{"name":[{}],"retryPolicy":{"maxAttempts":5,"initialBackoff":"0.1s","maxBackoff":"1s","backoffMultiplier":2,"retryableStatusCodes":["UNAVAILABLE"]}}]}`)) -
88% 成功率
Tune keepalive to detect dead transports faster: grpc.WithKeepaliveParams(keepalive.ClientParameters{Time: 30*time.Second, Timeout: 10*time.Second, PermitWithoutStream: true})
无效尝试
常见但无效的做法:
-
85% 失败
WithBlock only affects dial; the in-flight RPC still fails with Unavailable.
-
70% 失败
Keepalive is what detects dead transports; disabling it hides the symptom but leaves zombie connections.