DEADLINE_EXCEEDED api runtime_error ai_generated true

gRPC 错误:DEADLINE_EXCEEDED:等待流响应超时

gRPC error: DEADLINE_EXCEEDED: deadline exceeded waiting for stream response

ID: api/grpc-deadline-exceeded-streaming

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

版本兼容性

版本状态引入弃用备注
gRPC 1.58 active
gRPC-Go 1.60 active
gRPC-Java 1.61 active
Envoy 1.28 active

根因分析

客户端设置的截止时间(超时)在服务器完成发送所有流消息之前到期,通常由于长时间流上的慢处理或网络延迟。

English

Client-set deadline (timeout) expired before the server finished sending all stream messages, often due to slow processing or network latency on long-lived streams.

generic

官方文档

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

解决方案

  1. 为每个 RPC 设置与预期流持续时间匹配的截止时间。对于服务器流式 RPC,使用较长的截止时间(例如 60 秒)并实现 keepalive ping 以检测死连接。
  2. 在服务器端实现带有背压的流式传输:使用流量控制防止服务器发送速度超过客户端消费速度,减少因缓冲导致截止时间超时的风险。

无效尝试

常见但无效的做法:

  1. 75% 失败

    Unbounded timeouts mask underlying performance issues and may cause resource leaks; the correct fix is per-stream or per-RPC tuning, not a global increase.

  2. 90% 失败

    This removes timeout protection, leading to hung connections and resource exhaustion; gRPC requires deadlines for reliability.