# 读取上游时上游超时（110：连接超时），客户端：10.0.0.1，服务器：stream.example.com

- **ID:** `nginx/proxy-read-timeout-streaming`
- **领域:** nginx
- **类别:** timeout_error
- **错误码:** `110`
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

proxy_read_timeout 对流式或长轮询响应设置过短，导致 nginx 在上游完成发送数据前关闭连接。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| nginx/1.18.0 | active | — | — |
| nginx/1.20.0 | active | — | — |
| nginx/1.24.0 | active | — | — |
| nginx/1.26.0 | active | — | — |

## 解决方案

1. ```
   在 location 或 server 块中将 proxy_read_timeout 增加到 300 秒（或更高）：`location /stream { proxy_read_timeout 300s; ... }`
   ```
2. ```
   对于流式端点，添加 send_timeout 指令以避免客户端超时：`send_timeout 300s;`
   ```
3. ```
   在上游实现 keepalive 以减少连接开销：`upstream backend { server 127.0.0.1:8080; keepalive 32; }` 和 `proxy_http_version 1.1; proxy_set_header Connection '';`
   ```

## 无效尝试

- **** — proxy_connect_timeout controls the initial handshake, not the data transfer phase; the timeout occurs during reading, not connecting. (80% 失败率)
- **** — Keepalive affects connection reuse, not the per-request timeout for reading response data. (40% 失败率)
- **** — Infinite timeout can accumulate zombie connections, eventually exhausting worker connections or memory. (60% 失败率)
