go network_error ai_generated partial

rpc 错误:code = DataLoss,desc = 流被 RST_STREAM 终止,错误码:INTERNAL_ERROR

rpc error: code = DataLoss desc = stream terminated by RST_STREAM with error code: INTERNAL_ERROR

ID: go/grpc-data-loss-stream-reset

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

版本兼容性

版本状态引入弃用备注
google.golang.org/grpc 1.52+ active — — —

根因分析

HTTP/2 流被对端重置,通常由于代理(Envoy/nginx)终止长连接流或服务端 bug。

English

The HTTP/2 stream was reset by the peer, often due to a proxy (Envoy/nginx) killing long-lived streams or a server bug.

generic

解决方案

  1. 90% 成功率
    Align proxy timeouts with gRPC keepalive:
    // Envoy
    stream_idle_timeout: 0s
    // client
    grpc.WithKeepaliveParams(keepalive.ClientParameters{Time: 30*time.Second, Timeout: 10*time.Second})
  2. 85% 成功率
    Implement stream reconnection with jittered exponential backoff and resume from the last received cursor (application-level checkpointing).

无效尝试

常见但无效的做法:

  1. 85% 失败

    RST_STREAM is a peer-initiated reset, not a timeout; a longer deadline won't stop it.

  2. 80% 失败

    Reconnect storms against a misbehaving proxy worsen the outage.