grpc runtime_error ai_generated true

DEADLINE_EXCEEDED: 客户端空闲超时已超出

DEADLINE_EXCEEDED: client idle timeout exceeded

ID: grpc/deadline-exceeded-client-idle-timeout

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

版本兼容性

版本状态引入弃用备注
gRPC v1.60.0 active — — —
gRPC v1.65.0 active — — —
gRPC-Java v1.62.0 active — — —

根因分析

gRPC客户端通道空闲超时(默认30分钟)在发起任何RPC之前到期,导致通道关闭,挂起的调用失败。

English

gRPC client channel idle timeout (default 30 minutes) expired before any RPC was made, causing the channel to close and pending calls to fail.

generic

官方文档

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

解决方案

  1. 禁用空闲超时:设置通道参数'grpc.idle_timeout=0'(Python: 'grpc.insecure_channel(target, options=[("grpc.idle_timeout", 0)])')以保持通道无限期打开。
  2. 启用保活ping以防止空闲超时:配置'grpc.keepalive_time_ms=10000'、'grpc.keepalive_timeout_ms=5000'和'grpc.keepalive_permit_without_calls=1'以维持通道活动。
  3. 安排定期健康检查RPC(如每20分钟一次)以重置空闲计时器;使用轻量级的'HealthCheck'服务调用保持通道活跃。

无效尝试

常见但无效的做法:

  1. 95% 失败

    Reducing the RPC deadline (e.g., from 10s to 5s) doesn't fix the idle timeout; the channel still closes after the idle period.

  2. 80% 失败

    Increasing client keepalive time (e.g., 'grpc.keepalive_time=10s') without enabling keepalive ping prevents timeout because keepalive is disabled by default for idle channels.

  3. 70% 失败

    Recreating the channel on each RPC avoids idle timeout but introduces high latency and resource overhead, potentially causing other errors like 'RESOURCE_EXHAUSTED'.