# DEADLINE_EXCEEDED: grpc: 流 456 上的写入超时，超过 10000ms

- **ID:** `grpc/write-deadline-exceeded-on-stream`
- **领域:** grpc
- **类别:** network_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

服务器写入数据到流的时间过长，超过了配置的写入超时，通常由于网络缓慢或 I/O 阻塞。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| gRPC C++ 1.60.0 | active | — | — |
| gRPC Core 1.61.0 | active | — | — |
| gRPC Ruby 1.62.0 | active | — | — |

## 解决方案

1. ```
   通过通道参数配置写入超时：`export GRPC_ARG_HTTP2_WRITE_BUFFER_SIZE=65536` 并设置 `GRPC_ARG_KEEPALIVE_TIME_MS=10000` 以更快检测死连接
   ```
2. ```
   在服务器代码中，使用独立的 goroutine 配合 `context.WithTimeout` 处理写入操作，优雅处理慢客户端
   ```

## 无效尝试

- **Increase the overall RPC deadline only, ignoring write deadline** — Write deadline is separate; increased RPC deadline won't fix write-specific timeout. (70% 失败率)
- **Restart the server to clear the stream state** — The underlying network issue or blocking I/O persists. (80% 失败率)
- **Set a very large write deadline (e.g., 60s) without investigating root cause** — Masks the issue; slow writes can still cause user-perceived timeouts. (50% 失败率)
