Skip to content

Commit 7427d6b

Browse files
authored
docs: enhance data read timeout configuration to include connection reuse behavior
1 parent d68c421 commit 7427d6b

File tree

2 files changed

+50
-22
lines changed

2 files changed

+50
-22
lines changed

docs/en/configuration.md

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,26 +125,40 @@ Example:
125125
nodepass "client://server.example.com:10101/127.0.0.1:8080?min=32"
126126
```
127127

128-
## Data Read Timeout
129-
Data read timeout can be set using the URL query parameter `read`, with units in seconds or minutes:
130-
- `read`: Data read timeout (default: 1 hour)
131-
- Value format: integer followed by optional unit (`s` for seconds, `m` for minutes)
132-
- Examples: `30s` (30 seconds), `5m` (5 minutes), `1h` (1 hour)
128+
## Data Read Timeout and Connection Reuse
129+
130+
The `read` parameter controls both data read timeout and connection pool reuse behavior:
131+
132+
- `read`: Data read timeout and connection reuse (default: 0, meaning no timeout and no connection recycling)
133+
- Value 0 or omitted: No data read timeout, connections are not recycled to the pool after data transfer completes
134+
- Positive integer with time unit: Sets read timeout and enables connection reuse
135+
- Value format: integer followed by unit (`s` for seconds, `m` for minutes, `h` for hours)
136+
- Examples: `30s` (30 seconds), `5m` (5 minutes), `1h` (1 hour)
137+
- If no data is received within the timeout period, the connection is closed
138+
- After data transfer completes, the connection is recycled to the pool for reuse
133139
- Applies to both client and server modes
134-
- If no data is received within the timeout period, the connection is closed
135140

136141
Example:
137142
```bash
138-
# Set data read timeout to 5 minutes
143+
# Set data read timeout to 5 minutes, enable connection reuse
139144
nodepass "client://server.example.com:10101/127.0.0.1:8080?read=5m"
140145

141-
# Set data read timeout to 30 seconds for fast-response applications
146+
# Set data read timeout to 30 seconds for fast-response applications, enable connection reuse
142147
nodepass "client://server.example.com:10101/127.0.0.1:8080?read=30s"
143148

144-
# Set data read timeout to 30 minutes for long-running transfers
145-
nodepass "client://server.example.com:10101/127.0.0.1:8080?read=30m"
149+
# Set data read timeout to 1 hour for long-running transfers, enable connection reuse
150+
nodepass "client://server.example.com:10101/127.0.0.1:8080?read=1h"
151+
152+
# Default behavior: no timeout and no connection recycling (omit read parameter or set to 0)
153+
nodepass "client://server.example.com:10101/127.0.0.1:8080"
146154
```
147155

156+
**Connection Reuse Use Cases:**
157+
- **HTTP Short Connections**: Set reasonable read timeout and enable connection reuse for frequent short connections to improve pool utilization
158+
- **Long Connection Optimization**: Set larger timeout values for long-lived connections while avoiding resource waste
159+
- **Resource Control**: Enable connection recycling by setting timeout in scenarios requiring strict connection lifecycle control
160+
- **Default Mode**: Use the default no-timeout no-recycling mode for scenarios requiring maximum flexibility
161+
148162
## Rate Limiting
149163
NodePass supports bandwidth rate limiting for traffic control through the `rate` parameter. This feature helps prevent network congestion and ensures fair resource allocation across multiple connections.
150164

@@ -263,7 +277,7 @@ NodePass allows flexible configuration via URL query parameters. The following t
263277
| `min` | Minimum pool capacity | `64` | X | O | X |
264278
| `max` | Maximum pool capacity | `1024` | O | X | X |
265279
| `mode` | Run mode control | `0` | O | O | X |
266-
| `read` | Data read timeout | `1h` | O | O | X |
280+
| `read` | Data read timeout and connection reuse | `0` | O | O | X |
267281
| `rate` | Bandwidth rate limit | `0` | O | O | X |
268282
| `slot` | Maximum connection limit | `65536` | O | O | X |
269283
| `proxy` | PROXY protocol support| `0` | O | O | X |

docs/zh/configuration.md

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,26 +125,40 @@ nodepass "server://0.0.0.0:10101/remote.example.com:8080?mode=2"
125125
nodepass "client://server.example.com:10101/127.0.0.1:8080?min=32"
126126
```
127127

128-
## 数据读取超时
129-
数据读取超时可以通过URL查询参数`read`设置,单位为秒或分钟:
130-
- `read`: 数据读取超时时间(默认: 1小时)
131-
- 值格式:整数后跟可选单位(`s`表示秒,`m`表示分钟)
132-
- 示例:`30s`(30秒),`5m`(5分钟),`1h`(1小时)
128+
## 数据读取超时与连接重用
129+
130+
`read`参数用于控制数据读取超时时间和连接池连接的重用行为:
131+
132+
- `read`: 数据读取超时时间(默认: 0,表示无超时且不回收连接)
133+
- 值为0或省略:无数据读取超时,连接在数据传输完成后不回收到连接池
134+
- 正整数加时间单位:设置读取超时时间,并启用连接重用
135+
- 值格式:整数后跟单位(`s`表示秒,`m`表示分钟,`h`表示小时)
136+
- 示例:`30s`(30秒),`5m`(5分钟),`1h`(1小时)
137+
- 如果在超时时间内未接收到数据,连接将被关闭
138+
- 数据传输完成后,连接将被回收到连接池供重用
133139
- 适用于客户端和服务端模式
134-
- 如果在超时时间内未接收到数据,连接将被关闭
135140

136141
示例:
137142
```bash
138-
# 设置数据读取超时为5分钟
143+
# 设置数据读取超时为5分钟,启用连接重用
139144
nodepass "client://server.example.com:10101/127.0.0.1:8080?read=5m"
140145

141-
# 设置数据读取超时为30秒,适用于快速响应应用
146+
# 设置数据读取超时为30秒,适用于快速响应应用,启用连接重用
142147
nodepass "client://server.example.com:10101/127.0.0.1:8080?read=30s"
143148

144-
# 设置数据读取超时为30分钟,适用于长时间传输
145-
nodepass "client://server.example.com:10101/127.0.0.1:8080?read=30m"
149+
# 设置数据读取超时为1小时,适用于长时间传输,启用连接重用
150+
nodepass "client://server.example.com:10101/127.0.0.1:8080?read=1h"
151+
152+
# 默认行为:无超时且不回收连接(省略read参数或设置为0)
153+
nodepass "client://server.example.com:10101/127.0.0.1:8080"
146154
```
147155

156+
**连接重用使用场景:**
157+
- **HTTP短连接**:为频繁的短连接设置合理的读取超时并启用连接重用,提高连接池利用率
158+
- **长连接优化**:为长时间保持的连接设置较大的超时值,同时避免资源浪费
159+
- **资源控制**:在需要严格控制连接生命周期的场景下,通过设置超时启用连接回收
160+
- **默认模式**:对于需要最大灵活性的场景,使用默认的无超时不回收模式
161+
148162
## 速率限制
149163
NodePass支持通过`rate`参数进行带宽速率限制,用于流量控制。此功能有助于防止网络拥塞,确保多个连接间的公平资源分配。
150164

@@ -263,7 +277,7 @@ NodePass支持通过URL查询参数进行灵活配置,不同参数在 server
263277
| `min` | 最小连接池容量 | `64` | X | O | X |
264278
| `max` | 最大连接池容量 | `1024` | O | X | X |
265279
| `mode` | 运行模式控制 | `0` | O | O | X |
266-
| `read` | 读取超时时间 | `1h` | O | O | X |
280+
| `read` | 数据读取超时与连接重用 | `0` | O | O | X |
267281
| `rate` | 带宽速率限制 | `0` | O | O | X |
268282
| `slot` | 最大连接数限制 | `65536` | O | O | X |
269283
| `proxy` | PROXY协议支持 | `0` | O | O | X |

0 commit comments

Comments
 (0)