GRPC_STREAM_IDLE_TIMEOUT grpc runtime_error ai_generated true

内部错误:gRPC 流 45 因空闲超时关闭

INTERNAL: grpc: stream 45 closed with error: stream idled out

ID: grpc/stream-idle-timeout-reset

其他格式: JSON · Markdown 中文 · English
82%修复率
85%置信度
1证据数
2024-03-15首次发现

版本兼容性

版本状态引入弃用备注
gRPC v1.50.x active
gRPC v1.62.x active
gRPC v1.64.x active

根因分析

gRPC 服务器因每流空闲超时配置关闭了空闲流,通常由客户端在超时窗口内未发送数据引起。

English

gRPC server closed an idle stream due to per-stream idle timeout configuration, often caused by client not sending data within the timeout window.

generic

官方文档

https://grpc.io/docs/guides/keepalive/

解决方案

  1. 增加服务器端流空闲超时时间:在 Python 中设置 `grpc.max_connection_idle_ms` 为 60000 毫秒,或 C++ 中设置 `GRPC_ARG_MAX_CONNECTION_IDLE_MS`,避免空闲流过早关闭。
  2. 客户端定期发送数据或心跳消息(每 10-15 秒),保持流活跃。
  3. 降低服务器 `max_connection_age_ms` 和 `max_connection_age_grace_ms`,强制连接重新平衡,重置空闲计数器。

无效尝试

常见但无效的做法:

  1. 70% 失败

    Keepalive pings prevent connection-level idle, but per-stream idle timeouts are separate and not affected by keepalive pings.

  2. 60% 失败

    This controls minimum allowed ping interval, not stream idle timeout; it doesn't prevent stream closure due to inactivity.

  3. 50% 失败

    Removing keepalive can cause connection drops, but stream idle timeout is a separate server-side policy that still applies.