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

If any workaround for proxy support? #472

Closed
birbird opened this issue Sep 16, 2018 · 3 comments
Closed

If any workaround for proxy support? #472

birbird opened this issue Sep 16, 2018 · 3 comments

Comments

@birbird
Copy link

birbird commented Sep 16, 2018

This library has the limitation "The client doesn’t support connecting through a proxy".
My situation is that I have to use a proxy. May I ask if any workaround for proxy?
Any help will be highly appreciated.

@aaugustin
Copy link
Member

aaugustin commented Sep 17, 2018

It's going to take some manual work.

You could establish the connection to the proxy yourself (looking at #422 may help) than pass the already connected socket with the sock argument to connect.

@ChyiYaqing
Copy link

Listen to you suggestion to establish the connection to the proxy , then pass the already connected socket with the sock argument.

try:
	proxy_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	proxy_sock.connect(("127.0.0.1", 1080))
except Exception as err:
	print(err)

async def getStream():
       async with websockets.connect("wss//stream.xxx.com:xxx", sock=proxy_sock) as websocket:
                message = await websocket.recv()

But get the "asyncio Value Error - ValueError: You must set server_hostname when using ssl without a host".

Please give me some other suggestions. Thank You.

@aaugustin
Copy link
Member

You need to do the HTTP request to connect to the proxy before passing the sock argument to connect.

To be honest "it's going to take some manual work" was an euphemism for "you're going to hate this".

Then, if you're doing a WSS connection inside the proxy connection, you must pass a server_hostname to connect like the error message tells you.

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

No branches or pull requests

3 participants