-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
ws_connect doesn't follow proxy from environment #4648
Copy link
Copy link
Closed
Description
🐞 Describe the bug
I have set both http_proxy and https_proxy, with trust_env=True when create ClientSession,
everything is ok when get or post with this session, but for the ws_connect, It doesn't run with proxy.
💡 To Reproduce
background: I cann't visit wss://stream.binance.com:9443/ws under my network but it's ok with proxy
- prepare a proxy at port 1086
- http_proxy="http://127.0.0.1:1086"
- https_proxy="https://127.0.0.1:1086"
import asyncio
import aiohttp
async def main():
async with aiohttp.ClientSession(trust_env=True) as client:
await client.ws_connect('wss://stream.binance.com:9443/ws')
print('ok')
loop = asyncio.get_event_loop()
loop.run_until_complete(main())and it block forever (with a tcp handshake timeout exception)
💡 Expected behavior
just connect with proxy
📋 Logs/tracebacks
📋 Your version of the Python
$ python --version
Python 3.7.6📋 Your version of the aiohttp/yarl/multidict distributions
$ python -m pip show aiohttp
Version: 3.6.2$ python -m pip show multidict
Version: 4.7.5$ python -m pip show yarl
Version: 1.1.0📋 Additional context
Line 426 in bb7a4ea
| if scheme == url.scheme: |
scheme of websocket is ws or wss, url.scheme will always be http or https and ignore any other proxy here
Line 232 in bb7a4ea
| if k in ('http', 'https')} |
but it's ok for ws/wss to use http proxy
Reactions are currently unavailable