go network_error ai_generated true

rpc error: code = Unknown desc = unexpected EOF

ID: go/grpc-status-code-mismatch

Also available as: JSON · Markdown · 中文
80%Fix Rate
82%Confidence
0Evidence
2024-05-22First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.5 active

Root Cause

The gRPC stream is abruptly closed, possibly due to a network issue or server crash, and the client receives an EOF without a proper status code.

generic

中文

gRPC 流被突然关闭,可能是由于网络问题或服务器崩溃,客户端收到 EOF 而没有正确的状态码。

Workarounds

  1. 85% success Use a new connection for retries
    conn, _ := grpc.NewClient("localhost:50051", grpc.WithTransportCredentials(insecure.NewCredentials()))
    defer conn.Close()
  2. 75% success Enable keepalive and connection recovery
    grpc.WithKeepaliveParams(keepalive.ClientParameters{Time: 10 * time.Second, Timeout: 3 * time.Second, PermitWithoutStream: true})

Dead Ends

Common approaches that don't work:

  1. Retry the RPC immediately with the same connection 80% fail

    The connection is likely broken, so retrying on the same connection will fail again.

  2. Ignore the error and assume the response is empty 100% fail

    The RPC did not complete successfully, so the response is invalid.