# rpc 错误：code = DataLoss，desc = 流被 RST_STREAM 终止，错误码：INTERNAL_ERROR

- **ID:** `go/grpc-data-loss-stream-reset`
- **领域:** go
- **类别:** network_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

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

## 版本兼容性

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

## 解决方案

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).
   ```

## 无效尝试

- **** — RST_STREAM is a peer-initiated reset, not a timeout; a longer deadline won't stop it. (85% 失败率)
- **** — Reconnect storms against a misbehaving proxy worsen the outage. (80% 失败率)
