Skip to content

Commit 0169589

Browse files
fix(providers): disable keep-alive reuse in AsyncOpenAI to avoid SSL UNEXPECTED_EOF from gateway idle-connection reaping (scnet)
1 parent b6bedf2 commit 0169589

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

core/providers/openai_compat.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
)
3131
from openai import AsyncOpenAI
3232

33+
import httpx
34+
3335
from core.providers.base import (
3436
LLMProvider,
3537
LLMResponse,
@@ -259,6 +261,12 @@ def __init__(
259261
default_headers=default_headers,
260262
max_retries=0,
261263
timeout=_get_default_request_timeout_s(),
264+
# 禁用 keep-alive 连接复用:第三方网关(如 scnet)会回收空闲连接,
265+
# 复用被回收的死连接会触发 SSL: UNEXPECTED_EOF_WHILE_READING。
266+
# 每次请求新建连接,代价 ~50-100ms 握手,对 LLM 秒级请求可忽略。
267+
http_client=httpx.AsyncClient(
268+
limits=httpx.Limits(max_keepalive_connections=0),
269+
),
262270
)
263271

264272
# Responses API circuit breaker: skip after repeated failures,

0 commit comments

Comments
 (0)