Skip to content

Commit a162e2f

Browse files
committed
fix: resolve 60s streaming timeout with Connection: close
Signed-off-by: Xin Liu <[email protected]>
1 parent b79d7dd commit a162e2f

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/proxy/http_proxy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl HttpProxy {
8484
let body_stream = stream.map(|result| {
8585
result.map_err(|e| {
8686
error!("Error reading response stream: {}", e);
87-
std::io::Error::other(e)
87+
std::io::Error::new(std::io::ErrorKind::Other, e)
8888
})
8989
});
9090

tests/mock-data/mock-openai-stream.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ def send_streaming_response(self, request_data):
4646
self.send_response(200)
4747
self.send_header('Content-Type', 'text/event-stream')
4848
self.send_header('Cache-Control', 'no-cache')
49-
self.send_header('Connection', 'keep-alive')
49+
self.send_header("Connection", "close") # 明确关闭连接
50+
self.send_header("X-Accel-Buffering", "no") # 禁用缓冲
5051
self.end_headers()
5152

5253
# Simulate streaming chunks
@@ -76,8 +77,8 @@ def send_streaming_response(self, request_data):
7677
self.wfile.write(data.encode('utf-8'))
7778
self.wfile.flush()
7879

79-
# Simulate processing delay
80-
time.sleep(0.1)
80+
# Simulate processing delay (reduced for faster tests)
81+
time.sleep(0.05) # 50ms instead of 100ms
8182

8283
# Send final chunk
8384
final_chunk = {

0 commit comments

Comments
 (0)