, HTTPSConnectionPool(host='www.dmxapi.cn', port=443): Max retries exceeded with...
🚨 错误信息
Run failed: [models] Server Unavailable Error, HTTPSConnectionPool(host='www.dmxapi.cn', port=443): Max retries exceeded with url: /v1/chat/completions (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7fdcaaedc0b0>, 'Connection to www.dmxapi.cn timed out. (connect timeout=10)'))
🤖 AI解决方案
错误翻译
原文:HTTPSConnectionPool(host='www.dmxapi.cn', port=443): Max retries exceeded with url: /v1/chat/completions (Caused by ConnectTimeoutError(, 'Connection to www.dmxapi.cn timed out. (connect timeout=10)'))
译文:HTTPS连接池(主机='www.dmxapi.cn', 端口=443): 达到最大重试次数,URL: /v1/chat/completions (原因为连接超时错误,连接到www.dmxapi.cn超时(连接超时时间为10秒))
原因分析
网络连接超时:尝试连接DMXAPI服务器(www.dmxapi.cn)时,在10秒内未能建立连接,达到最大重试次数后失败。
解决方案
python
方案1:增加超时时间
import requests
import urllib3增加连接超时时间(例如设为30秒)
response = requests.post(
'https://www.dmxapi.cn/v1/chat/completions',
timeout=(10, 30) # 连接超时10秒,读取超时30秒
)方案2:添加重试机制
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retrysession = requests.Session()
retry_strategy = Retry(
total=3,
backoff_factor=1,
status_forcelist=[429, 500, 502, 503, 504],
)
adapter = HTTPAdapter(max_retries=retry_strategy)
session.mount("http://", adapter)
session.mount("https://", adapter)
response = session.post('https://www.dmxapi.cn/v1/chat/completions', timeout=30)
️ 预防措施
推荐工具:
ping www.dmxapi.cn检查网络连通性