# rpc error: code = Internal desc = 流被 RST_STREAM 终止，错误码：PROTOCOL_ERROR

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

## 根因

HTTP/2 流被对端重置，通常由服务端处理器中的 panic、超出流控限制，或代理（Envoy/nginx）重置连接引起。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.x | active | — | — |

## 解决方案

1. **** (88% 成功率)
   ```
   func recoverInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, h grpc.UnaryHandler) (any, error) {
  defer func() { if r := recover(); r != nil { log.Printf("panic: %v", r) } }()
  return h(ctx, req)
}
s := grpc.NewServer(grpc.UnaryInterceptor(recoverInterceptor))
   ```
2. **** (70% 成功率)
   ```
   // Envoy example: set stream_idle_timeout: 0s or raise it in HttpConnectionManager config
   ```

## 无效尝试

- **** — If a handler panics deterministically, every stream resets. (80% 失败率)
- **** — gRPC requires HTTP/2; disabling it breaks all calls. (95% 失败率)
