go network_error ai_generated partial

rpc error: code = Internal desc = stream terminated by RST_STREAM with error code: PROTOCOL_ERROR

ID: go/grpc-internal-stream-terminated

Also available as: JSON · Markdown · 中文
80%Fix Rate
82%Confidence
0Evidence
2024-08-05First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.x active — — —

Root Cause

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.

generic

中文

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

Workarounds

  1. 88% success
    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% success
    // Envoy example: set stream_idle_timeout: 0s or raise it in HttpConnectionManager config

Dead Ends

Common approaches that don't work:

  1. 80% fail

    If a handler panics deterministically, every stream resets.

  2. 95% fail

    gRPC requires HTTP/2; disabling it breaks all calls.