go network_error ai_generated true

rpc 错误:代码 = Unavailable 描述 = 传输正在关闭

rpc error: code = Unavailable desc = transport is closing

ID: go/grpc-connection-reset

其他格式: JSON · Markdown 中文 · English
80%修复率
85%置信度
0证据数
2024-10-02首次发现

版本兼容性

版本状态引入弃用备注
1.10 active

根因分析

gRPC 连接在调用进行中关闭,通常由于服务器关闭或网络问题。

English

The gRPC connection is closed while a call is in progress, often due to server shutdown or network issues.

generic

解决方案

  1. 70% 成功率
    for i := 0; i < 3; i++ { err := client.Call(ctx, req); if err == nil { break }; time.Sleep(time.Duration(i)*time.Second) }
  2. 90% 成功率
    conn, _ := grpc.Dial("addr", grpc.WithInsecure()); client := pb.NewClient(conn)

无效尝试

常见但无效的做法:

  1. 80% 失败

    If the server is down, retry will fail again.

  2. 60% 失败

    Keepalive doesn't prevent abrupt connection resets.