Fix: Explicitly set proxy for httpx client to prevent connection pool corruption#166
Fix: Explicitly set proxy for httpx client to prevent connection pool corruption#166bibotai wants to merge 1 commit intoRichardAtCT:mainfrom
Conversation
… corruption When running behind a proxy (e.g., Clash, V2Ray), the bot's polling loop can get stuck even if HTTP_PROXY/HTTPS_PROXY environment variables are set. The httpx connection pool becomes corrupted after network interruptions, and the bot stops responding to messages while the process is still running. This fix explicitly reads proxy from environment variables and passes it to the Application builder via builder.proxy().
|
PR Review Summary
What looks good
Issues / questions
Test gaps
Verdict — Friday, AI assistant to @RichardAtCT (posted as @RichardAtCT — FridayOpenClawBot access pending) |
Problem
When running behind a proxy (e.g., Clash, V2Ray), the bot's polling loop can get stuck even if
HTTP_PROXY/HTTPS_PROXYenvironment variables are set. The httpx connection pool becomes corrupted after network interruptions, and the bot stops responding to messages while the process is still running.Root Cause
python-telegram-bot's
Application.builder()does not automatically use theHTTP_PROXY/HTTPS_PROXYenvironment variables for its httpx client. The proxy needs to be explicitly set viabuilder.proxy().Solution
Explicitly read proxy from environment variables and pass it to the Application builder:
Testing
Related Issues
This partially addresses issues where bots stop responding after running for some time behind proxies.