Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ws_connect doesn't follow proxy from environment #4648

Closed
lookis opened this issue Mar 19, 2020 · 1 comment · Fixed by #4661
Closed

ws_connect doesn't follow proxy from environment #4648

lookis opened this issue Mar 19, 2020 · 1 comment · Fixed by #4661

Comments

@lookis
Copy link

lookis commented Mar 19, 2020

🐞 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

  1. prepare a proxy at port 1086
  2. http_proxy="http://127.0.0.1:1086"
  3. 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

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
if k in ('http', 'https')}

but it's ok for ws/wss to use http proxy

@lookis lookis added the bug label Mar 19, 2020
@webknjaz
Copy link
Member

Feel free to send a PR with tests bundled.

mmasztalerczuk added a commit to mmasztalerczuk/aiohttp that referenced this issue Mar 24, 2020
mmasztalerczuk added a commit to mmasztalerczuk/aiohttp that referenced this issue Mar 24, 2020
mmasztalerczuk added a commit to mmasztalerczuk/aiohttp that referenced this issue Mar 24, 2020
@helpr helpr bot added the pr-available label Mar 25, 2020
webknjaz added a commit that referenced this issue Mar 26, 2020
PR #4661

Resolves #4648

Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
@helpr helpr bot added pr-merged and removed pr-available labels Mar 26, 2020
asvetlov pushed a commit that referenced this issue Oct 16, 2020
PR #4661

Resolves #4648

Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
icamposrivera pushed a commit to icamposrivera/aiohttp that referenced this issue Oct 21, 2021
PR aio-libs#4661

Resolves aio-libs#4648

Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
webknjaz pushed a commit to webknjaz/aiohttp that referenced this issue Oct 31, 2021
PR aio-libs#4661

Resolves aio-libs#4648

Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
(cherry picked from commit 50753ea)
webknjaz pushed a commit to webknjaz/aiohttp that referenced this issue Oct 31, 2021
PR aio-libs#4661

Resolves aio-libs#4648

Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
(cherry picked from commit 50753ea)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants