fix(telegram): pass proxy URL explicitly to HTTPXRequest when proxy env vars are set - #8931
Closed
MaybeRichard wants to merge 1 commit into
Closed
fix(telegram): pass proxy URL explicitly to HTTPXRequest when proxy env vars are set#8931MaybeRichard wants to merge 1 commit into
MaybeRichard wants to merge 1 commit into
Conversation
…s configured When HTTPS_PROXY/HTTP_PROXY/ALL_PROXY env vars are set, the code already detects proxy_configured=True and skips the fallback-IP transport — but then creates HTTPXRequest(**request_kwargs) without an explicit proxy, relying solely on httpx's trust_env mechanism. In practice, trust_env alone is unreliable for HTTP CONNECT proxies (e.g. ClashMac / Clash in fake-ip mode): the TLS handshake performed inside the CONNECT tunnel can fail intermittently when httpcore's anyio backend is used, even though the same proxy works fine from curl or requests/urllib3. Fix: when proxy_configured is True, read the proxy URL from the environment and pass it explicitly via HTTPXRequest(..., proxy=proxy_url). This matches the explicit approach used in the aiohttp adapters (weixin/wecom/matrix) and is more robust than trust_env for users behind HTTP CONNECT proxies. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Author
|
The failing tests ( The |
teknium1
pushed a commit
that referenced
this pull request
Apr 13, 2026
…nv vars are set When HTTPS_PROXY / HTTP_PROXY / ALL_PROXY env vars are set (or macOS system proxy is detected), pass the proxy URL explicitly via HTTPXRequest(proxy=proxy_url) instead of relying on httpx's trust_env mechanism, which is unreliable for HTTP CONNECT proxies (e.g. Clash / ClashMac in fake-ip mode). Uses the shared resolve_proxy_url() from base.py (handles env vars + macOS system proxy detection) instead of duplicating env var reading inline. Consolidates the proxy_configured boolean into a single proxy_url = resolve_proxy_url() call that serves as both the gate for skipping fallback-IP transport and the value passed to HTTPXRequest. Co-authored-by: Hermes Agent <hermes@nousresearch.com> Salvaged from PR #8931 by MaybeRichard.
teknium1
pushed a commit
that referenced
this pull request
Apr 13, 2026
…nv vars are set When HTTPS_PROXY / HTTP_PROXY / ALL_PROXY env vars are set (or macOS system proxy is detected), pass the proxy URL explicitly via HTTPXRequest(proxy=proxy_url) instead of relying on httpx's trust_env mechanism, which is unreliable for HTTP CONNECT proxies (e.g. Clash / ClashMac in fake-ip mode). Uses the shared resolve_proxy_url() from base.py (handles env vars + macOS system proxy detection) instead of duplicating env var reading inline. Consolidates the proxy_configured boolean into a single proxy_url = resolve_proxy_url() call that serves as both the gate for skipping fallback-IP transport and the value passed to HTTPXRequest. Co-authored-by: Hermes Agent <hermes@nousresearch.com> Salvaged from PR #8931 by MaybeRichard.
Contributor
|
Merged via PR #8981. Your commit was cherry-picked onto current main with your authorship preserved in git log. Used the shared |
aj-nt
pushed a commit
to aj-nt/hermes-agent
that referenced
this pull request
May 1, 2026
…nv vars are set When HTTPS_PROXY / HTTP_PROXY / ALL_PROXY env vars are set (or macOS system proxy is detected), pass the proxy URL explicitly via HTTPXRequest(proxy=proxy_url) instead of relying on httpx's trust_env mechanism, which is unreliable for HTTP CONNECT proxies (e.g. Clash / ClashMac in fake-ip mode). Uses the shared resolve_proxy_url() from base.py (handles env vars + macOS system proxy detection) instead of duplicating env var reading inline. Consolidates the proxy_configured boolean into a single proxy_url = resolve_proxy_url() call that serves as both the gate for skipping fallback-IP transport and the value passed to HTTPXRequest. Co-authored-by: Hermes Agent <hermes@nousresearch.com> Salvaged from PR NousResearch#8931 by MaybeRichard.
02356abc
pushed a commit
to 02356abc/hermes-agent
that referenced
this pull request
May 14, 2026
…nv vars are set When HTTPS_PROXY / HTTP_PROXY / ALL_PROXY env vars are set (or macOS system proxy is detected), pass the proxy URL explicitly via HTTPXRequest(proxy=proxy_url) instead of relying on httpx's trust_env mechanism, which is unreliable for HTTP CONNECT proxies (e.g. Clash / ClashMac in fake-ip mode). Uses the shared resolve_proxy_url() from base.py (handles env vars + macOS system proxy detection) instead of duplicating env var reading inline. Consolidates the proxy_configured boolean into a single proxy_url = resolve_proxy_url() call that serves as both the gate for skipping fallback-IP transport and the value passed to HTTPXRequest. Co-authored-by: Hermes Agent <hermes@nousresearch.com> Salvaged from PR NousResearch#8931 by MaybeRichard.
gweeteve
pushed a commit
to gweeteve/hermes-agent
that referenced
this pull request
Jun 2, 2026
…nv vars are set When HTTPS_PROXY / HTTP_PROXY / ALL_PROXY env vars are set (or macOS system proxy is detected), pass the proxy URL explicitly via HTTPXRequest(proxy=proxy_url) instead of relying on httpx's trust_env mechanism, which is unreliable for HTTP CONNECT proxies (e.g. Clash / ClashMac in fake-ip mode). Uses the shared resolve_proxy_url() from base.py (handles env vars + macOS system proxy detection) instead of duplicating env var reading inline. Consolidates the proxy_configured boolean into a single proxy_url = resolve_proxy_url() call that serves as both the gate for skipping fallback-IP transport and the value passed to HTTPXRequest. Co-authored-by: Hermes Agent <hermes@nousresearch.com> Salvaged from PR NousResearch#8931 by MaybeRichard.
waefrebeorn
pushed a commit
to waefrebeorn/slermes
that referenced
this pull request
Jul 2, 2026
…nv vars are set When HTTPS_PROXY / HTTP_PROXY / ALL_PROXY env vars are set (or macOS system proxy is detected), pass the proxy URL explicitly via HTTPXRequest(proxy=proxy_url) instead of relying on httpx's trust_env mechanism, which is unreliable for HTTP CONNECT proxies (e.g. Clash / ClashMac in fake-ip mode). Uses the shared resolve_proxy_url() from base.py (handles env vars + macOS system proxy detection) instead of duplicating env var reading inline. Consolidates the proxy_configured boolean into a single proxy_url = resolve_proxy_url() call that serves as both the gate for skipping fallback-IP transport and the value passed to HTTPXRequest. Co-authored-by: Hermes Agent <hermes@nousresearch.com> Salvaged from PR NousResearch#8931 by MaybeRichard.
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.
Problem
When
HTTPS_PROXY/HTTP_PROXY/ALL_PROXYenv vars are set, the gateway correctly detectsproxy_configured=Trueand skips the fallback-IP transport — but then createsHTTPXRequest(**request_kwargs)without an explicitproxy=argument, relying solely on httpx'strust_envmechanism.In practice,
trust_envalone is unreliable when the proxy is an HTTP CONNECT proxy (e.g. Clash / ClashMac in fake-ip mode, common for users in China): the TLS handshake inside the CONNECT tunnel fails intermittently via httpcore's anyio backend, even though the same proxy works fine fromcurlorrequests/urllib3. The result is a flood ofhttpx.ConnectError/httpx.ConnectTimeouterrors and failed message delivery.Fix
When
proxy_configuredisTrue, read the proxy URL from the environment and pass it explicitly viaHTTPXRequest(..., proxy=proxy_url). This matches the explicit approach already used in the aiohttp-based adapters (weixin/wecom/matrix, see #8680) and is more robust thantrust_envfor users behind HTTP CONNECT proxies.Test
Verified on macOS with ClashMac proxy (
http://127.0.0.1:7890) in fake-ip mode. Before the fix: repeatedConnectError/TimedOuton polling and sends. After the fix: stable connection, messages delivered reliably.🤖 Generated with Claude Code