go
network_error
ai_generated
partial
rpc error: code = Internal desc = 流被 RST_STREAM 终止,错误码:PROTOCOL_ERROR
rpc error: code = Internal desc = stream terminated by RST_STREAM with error code: PROTOCOL_ERROR
ID: go/grpc-internal-stream-terminated
80%修复率
82%置信度
0证据数
2024-08-05首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 1.x | active | — | — | — |
根因分析
HTTP/2 流被对端重置,通常由服务端处理器中的 panic、超出流控限制,或代理(Envoy/nginx)重置连接引起。
English
HTTP/2 stream reset by the peer, often caused by server-side panic in a handler, exceeding flow control, or a proxy (Envoy/nginx) resetting the connection.
解决方案
-
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)) -
70% 成功率
// Envoy example: set stream_idle_timeout: 0s or raise it in HttpConnectionManager config
无效尝试
常见但无效的做法:
-
80% 失败
If a handler panics deterministically, every stream resets.
-
95% 失败
gRPC requires HTTP/2; disabling it breaks all calls.