go
network_error
ai_generated
partial
rpc 错误:code = Internal desc = transport: 传输正在关闭
rpc error: code = Internal desc = transport: transport is closing
ID: go/grpc-internal-transport-closing
80%修复率
85%置信度
0证据数
2024-09-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| google.golang.org/grpc 1.x | active | — | — | — |
根因分析
RPC 进行中时底层 HTTP/2 传输被关闭。原因包括服务端关闭、keepalive 超时,或代理(如 Envoy)关闭空闲连接。
English
The underlying HTTP/2 transport was closed while an RPC was in flight. Causes include server shutdown, keepalive timeout, or a proxy (e.g., Envoy) closing idle connections.
解决方案
-
85% 成功率
conn, _ := grpc.Dial(addr, grpc.WithKeepaliveParams(keepalive.ClientParameters{ Time: 30 * time.Second, Timeout: 10 * time.Second, PermitWithoutStream: true, }), ) -
80% 成功率
for { resp, err := client.Get(ctx, req) if err == nil { return resp, nil } c := status.Code(err) if c != codes.Internal && c != codes.Unavailable { return nil, err } time.Sleep(backoff.NextBackOff()) }
无效尝试
常见但无效的做法:
-
90% 失败
The response body is empty; downstream code will fail parsing nil/empty data.
-
80% 失败
WithBlock only affects initial dial; it does not prevent mid-call transport closure.