python
network_error
ai_generated
true
aiohttp.client_exceptions.ServerTimeoutError: Connection timeout to host https://slow.example.com
ID: python/aiohttp-connector-timeout
80%Fix Rate
86%Confidence
0Evidence
2024-07-03First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
| 3.12 | active | — | — | — |
Root Cause
The server did not complete the TCP/TLS handshake or respond within the configured aiohttp.ClientTimeout, often because of an overloaded endpoint or a too-aggressive default timeout.
generic中文
服务器未在配置的 aiohttp.ClientTimeout 内完成 TCP/TLS 握手或响应,通常是因为端点过载或超时设置过于激进。
Workarounds
-
90% success
timeout = aiohttp.ClientTimeout(total=30, connect=5, sock_read=10) async with aiohttp.ClientSession(timeout=timeout) as s: await s.get(url) -
85% success
for i in range(3): try: async with session.get(url) as r: return await r.text() except aiohttp.ServerTimeoutError: await asyncio.sleep(2 ** i)
Dead Ends
Common approaches that don't work:
-
90% fail
Hangs forever on dead hosts and exhausts connection pool slots.
-
75% fail
Handshake still fails on the sock_connect phase before the total timer matters.