go network_error ai_generated true

rpc error: code = Unavailable desc = transport is closing

ID: go/grpc-connection-reset

Also available as: JSON · Markdown · 中文
80%Fix Rate
85%Confidence
0Evidence
2024-10-02First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.10 active

Root Cause

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

generic

中文

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

Workarounds

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

Dead Ends

Common approaches that don't work:

  1. 80% fail

    If the server is down, retry will fail again.

  2. 60% fail

    Keepalive doesn't prevent abrupt connection resets.