-
Notifications
You must be signed in to change notification settings - Fork 603
Open
Labels
priority: p3Desirable enhancement or fix. May not be included in next release.Desirable enhancement or fix. May not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.
Description
When making multiple concurrent requests, the client often encounters intermittent aiohttp disconnection errors (e.g., aiohttp.client_exceptions.ServerDisconnectedError). This appears to stem from restrictive connection limits and insufficient keep-alive configurations in the default TCPConnector.
By increasing the connector limits and extending the keep-alive timeout, the client should maintain more stable and persistent connections under high concurrency.
Proposed Change
`
if self._aiohttp_session is None or self._aiohttp_session.closed:
AIOHTTP_CONNECTOR_LIMIT = 100
AIOHTTP_KEEPALIVE_TIMEOUT = 60
connector = aiohttp.TCPConnector(
limit=AIOHTTP_CONNECTOR_LIMIT,
keepalive_timeout=AIOHTTP_KEEPALIVE_TIMEOUT,
enable_cleanup_closed=True,
force_close=False # Reuse connections
)
self._aiohttp_session = aiohttp.ClientSession(
connector=connector,
trust_env=True,
read_bufsize=READ_BUFFER_SIZE,
)
`
Metadata
Metadata
Assignees
Labels
priority: p3Desirable enhancement or fix. May not be included in next release.Desirable enhancement or fix. May not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.