fix(gateway/telegram): reduce HTTPX pool-timeout failures during reconnect#6897
Closed
borischou wants to merge 1 commit into
Closed
fix(gateway/telegram): reduce HTTPX pool-timeout failures during reconnect#6897borischou wants to merge 1 commit into
borischou wants to merge 1 commit into
Conversation
- configure Telegram HTTPXRequest pool/timeouts with env-overridable defaults\n- use separate request/get_updates request objects to reduce pool contention\n- skip fallback-IP transport when proxy is configured (or explicitly disabled)\n\nThis mitigates recurrent pool-timeout failures during polling reconnect/bootstrap (delete_webhook).
Contributor
|
Merged via PR #7123. Your commit was cherry-picked onto current main with your authorship preserved. The HTTPX pool hardening is a real improvement — thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR hardens Telegram gateway networking under unstable connectivity and reconnect loops.
Changes
HTTPXRequestwith safer defaults (env-overridable):HERMES_TELEGRAM_HTTP_POOL_SIZE(default: 512)HERMES_TELEGRAM_HTTP_POOL_TIMEOUT(default: 8.0s)HERMES_TELEGRAM_HTTP_CONNECT_TIMEOUT(default: 10.0s)HERMES_TELEGRAM_HTTP_READ_TIMEOUT(default: 20.0s)HERMES_TELEGRAM_HTTP_WRITE_TIMEOUT(default: 20.0s)HTTPXRequestinstances for request and get-updates paths to reduce pool contentionWhy
Observed repeated runtime failures:
TimedOut: Pool timeout: All connections in the connection pool are occupieddelete_webhook)PTB default
pool_timeout=1.0sis too aggressive under transient network stress. Increasing pool budget/timeouts and reducing shared-path contention improves resilience.Validation
venv/bin/python -m pytest tests/gateway/test_telegram_network.py -q(45 passed)venv/bin/python -m pytest tests/gateway/test_telegram_network_reconnect.py tests/gateway/test_telegram_text_batching.py tests/gateway/test_telegram_reply_mode.py -q(34 passed)Notes
Behavior remains configurable via env vars; defaults are chosen for safer operation on flaky networks.