go network_error ai_generated true

rpc 错误:代码 = Unknown 描述 = 意外的 EOF

rpc error: code = Unknown desc = unexpected EOF

ID: go/grpc-status-code-mismatch

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

版本兼容性

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

根因分析

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

English

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

解决方案

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

无效尝试

常见但无效的做法:

  1. Retry the RPC immediately with the same connection 80% 失败

    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% 失败

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