v2.2.1: add 180s upstream timeout to prevent hanging connections
- All urlopen() calls now have timeout=180 to prevent infinite hangs - Crof upstream can idle between SSE chunks, causing proxy to block forever - Tested: kimi-k2.6 + mimo-v2.5-pro both stream completed successfully
This commit is contained in:
Binary file not shown.
@@ -1035,7 +1035,7 @@ class Handler(http.server.BaseHTTPRequestHandler):
|
||||
|
||||
if stream:
|
||||
try:
|
||||
upstream = urllib.request.urlopen(req)
|
||||
upstream = urllib.request.urlopen(req, timeout=180)
|
||||
except urllib.error.HTTPError as e:
|
||||
err = e.read().decode()
|
||||
return self.send_json(e.code, {"error": {"type": "upstream_error", "message": err}})
|
||||
@@ -1064,7 +1064,7 @@ class Handler(http.server.BaseHTTPRequestHandler):
|
||||
store_response(last_resp_id, body.get("input", ""), last_output)
|
||||
else:
|
||||
try:
|
||||
upstream = urllib.request.urlopen(req)
|
||||
upstream = urllib.request.urlopen(req, timeout=180)
|
||||
except urllib.error.HTTPError as e:
|
||||
err = e.read().decode()
|
||||
return self.send_json(e.code, {"error": {"type": "upstream_error", "message": err}})
|
||||
@@ -1081,7 +1081,7 @@ class Handler(http.server.BaseHTTPRequestHandler):
|
||||
|
||||
def _forward(self, req, stream, model, nonstream_fn, stream_fn, input_data=None):
|
||||
try:
|
||||
upstream = urllib.request.urlopen(req)
|
||||
upstream = urllib.request.urlopen(req, timeout=180)
|
||||
except urllib.error.HTTPError as e:
|
||||
err = e.read().decode()
|
||||
return self.send_json(e.code, {"error": {"type": "upstream_error", "message": err}})
|
||||
|
||||
Reference in New Issue
Block a user