Binance websocket stream over a proxy problem

122 views Asked by At

I tried using different private proxies from multiple proxy seller companies to fetch the Binance websocket stream "wss://stream.binance.com:9443" But I got websocket._exceptions.WebSocketProxyException: failed CONNECT via proxy status: 407.

The documentation on the Binance Python Connector allows proxies to be used. Screenshot

I was wondering if someone succeded in connecting with a proxy?

Thank you.

The code used to test.

import websocket

proxy_host = "proxy_ip"
proxy_port = 8080
proxy_user = "proxy_user"
proxy_password = "proxy_password"

# WebSocket URL
ws_url = "wss://stream.binance.com:9443"

websocket.enableTrace(True)

proxy_info = (proxy_host, proxy_port, proxy_user, proxy_password)
http_proxy_url = f"http://{proxy_user}:{proxy_password}@{proxy_host}:{proxy_port}"

ws = websocket.create_connection(ws_url, http_proxy_host=proxy_host, http_proxy_port=proxy_port, http_proxy_auth=(proxy_user, proxy_password))

ws.close()

Output.

Connecting proxy...
--- request header ---
CONNECT stream.binance.com:9443 HTTP/1.1
Host: stream.binance.com:9443
Proxy-Authorization: Basic MTR*************YzA5


-----------------------
--- response header ---
HTTP/1.1 407 Proxy Authentication Required
Server: squid/5.7
Mime-Version: 1.0
Date: Mon, 25 Dec 2023 11:34:44 GMT
Content-Type: text/html;charset=utf-8
Content-Length: 3515
X-Squid-Error: ERR_CACHE_ACCESS_DENIED 0
Vary: Accept-Language
Content-Language: en
Proxy-Authenticate: Basic realm="Username and password"
X-Cache: MISS from bugatti
X-Cache-Lookup: NONE from bugatti:12323
Connection: keep-alive
-----------------------
0

There are 0 answers