`RequestTimeout` on OKX due to missing `aiohttp_trust_env=True`
Description:
When initializing ccxt.async_support.okx() via CCXTExecutionGateway, the exchange fails to load markets (e.g., fetch_ticker('BTC/USDT:USDT')) with ccxt.base.errors.RequestTimeout, even though the same requests succeed via curl under identical proxy setup (HTTPS_PROXY=http://127.0.0.1:10808).
Evidence:
- ✅
curl -v "https://www.okx.com/api/v5/public/instruments?instType=FUTURES "succeeds. - ❌ Python runtime fails with:
okx GET https://www.okx.com/api/v5/public/instruments?instType=SPOT okx GET https://www.okx.com/api/v5/public/instruments?instType=FUTURES aiohttpattempts to connect to link-local169.254.0.2:443, confirming proxy is not used.- Code inspection reveals:
- Project loads
.env(incl.HTTPS_PROXY) at startup (app.py:41–69). - But
CCXTExecutionGatewayonly merges user config intooptions, not top-level keys likeaiohttp_trust_env. - Thus,
aiohttpnever readsHTTPS_PROXY, and requests go bare → time out or get DNS-routed to unreachable IPs.
- Project loads
Root Causes:
aiohttp_trust_env=True is not passed at top level of ccxt.async_support config → proxy ignored.
Impact:
- All async OKX calls fail (market data, execution, etc.).
- Affects all instrument types (
SPOT,FUTURES,SWAP). - Blocks local development & agent testing.
Hi @byronwang2005, thanks for the detailed report!
However, I would not recommend using the aiohttp_trust_env parameter to resolve this. We consider its invasiveness to be too high for a production-grade gateway.
Enabling trust_env=True forces aiohttp to implicitly read global system environment variables (like HTTP_PROXY / HTTPS_PROXY) for the session.
- Global Scope: It makes the application behavior dependent on the shell environment, which can lead to "it works on my machine" issues or unintentional routing of internal traffic through external proxies.
- Lack of Granularity: It applies to the session level, making it difficult to manage different proxy strategies for different exchanges or services within the same application.
ACK