Skip to content

fix: support HTTPS proxy agent for REST requests#21

Open
HunterXuanBot wants to merge 1 commit into
binance:masterfrom
HunterXuanBot:fix/https-proxy-agent-timeout
Open

fix: support HTTPS proxy agent for REST requests#21
HunterXuanBot wants to merge 1 commit into
binance:masterfrom
HunterXuanBot:fix/https-proxy-agent-timeout

Conversation

@HunterXuanBot
Copy link
Copy Markdown

@HunterXuanBot HunterXuanBot commented May 1, 2026

Bug Description

binance-cli currently fails to access HTTPS Binance REST endpoints through a standard HTTP forward proxy set via environment variables such as HTTPS_PROXY.

In restricted-location environments, users often need to route Binance API calls through an allowed proxy. With the current CLI, proxied HTTPS requests can fail with:

Request failed after 3 retries
AxiosError: timeout of 1000ms exceeded

Root Cause

The CLI reads API credentials/profile configuration but does not translate standard proxy environment variables into a proper HTTPS CONNECT agent for the REST connectors.

Axios' plain proxy configuration is not reliable for this HTTPS-over-HTTP proxy use case. The request should disable Axios proxy handling and use an HTTPS proxy agent instead.

Fix

  • Add https-proxy-agent as a runtime dependency.
  • Read proxy URLs from existing standard environment variables:
    • HTTPS_PROXY / https_proxy
    • HTTP_PROXY / http_proxy
  • When a proxy URL is present, configure REST clients with:
    • proxy: false
    • httpsAgent: new HttpsProxyAgent(proxyUrl)

How to Verify

  1. Run without a proxy from a restricted-location host and confirm Binance returns the existing restricted-location response.
  2. Run through an HTTP proxy that supports CONNECT:
HTTPS_PROXY=http://proxy.example:3128 \
binance-cli spot ticker-price --symbol BNBUSDT --profile <profile>
  1. Verify signed endpoints still work through the proxy:
HTTPS_PROXY=http://proxy.example:3128 \
binance-cli wallet get-api-key-permission --profile <profile>

Test Plan

  • npm run build
  • npm run typecheck
  • npm run lint
  • Manual verification of a public REST endpoint through an HTTP CONNECT proxy
  • Manual verification of a signed wallet endpoint through an HTTP CONNECT proxy

Risk Assessment

Low — this only changes behavior when standard proxy environment variables are set. Existing users without those variables keep the current behavior.

@HunterXuanBot HunterXuanBot force-pushed the fix/https-proxy-agent-timeout branch from e893d71 to 3cc9d89 Compare May 1, 2026 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant