使用代理连接Binance WebSocket流遇407认证错误求助
私有代理连接Binance WebSocket流遇407认证错误求助
尝试用多家代理服务商的私有代理获取Binance WebSocket流wss://stream.binance.com:9443,但持续报错:websocket._exceptions.WebSocketProxyException: failed CONNECT via proxy status: 407
Binance Python Connector的文档显示支持代理使用,想咨询是否有人成功通过代理建立过该连接?
测试代码
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()
输出日志
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 -----------------------
内容的提问来源于stack exchange,提问作者Zakariae Jaidi
相关产品推荐
相关产品推荐

