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

- **ID:** `grpc/deadline-exceeded-client-idle-timeout`
- **领域:** grpc
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 88%

## 根因

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

## 版本兼容性

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

## 解决方案

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'服务调用保持通道活跃。
   ```

## 无效尝试

- **** — Reducing the RPC deadline (e.g., from 10s to 5s) doesn't fix the idle timeout; the channel still closes after the idle period. (95% 失败率)
- **** — 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. (80% 失败率)
- **** — Recreating the channel on each RPC avoids idle timeout but introduces high latency and resource overhead, potentially causing other errors like 'RESOURCE_EXHAUSTED'. (70% 失败率)
