From 34f3d05c845653e0dfe9e67cfc5b0690f357bdbc Mon Sep 17 00:00:00 2001 From: AyliD Date: Thu, 29 Aug 2019 07:46:40 +0300 Subject: [PATCH] Update ws_client.py to support proxy --- stream/ws_client.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stream/ws_client.py b/stream/ws_client.py index a1a96f2d..0ffc1b44 100644 --- a/stream/ws_client.py +++ b/stream/ws_client.py @@ -74,7 +74,11 @@ def __init__(self, configuration, url, headers): ssl_opts['keyfile'] = configuration.key_file self.sock = WebSocket(sslopt=ssl_opts, skip_utf8_validation=False) - self.sock.connect(url, header=header) + if configuration.proxy: + proxy_url = urlparse(configuration.proxy) + self.sock.connect(url, header=header, http_proxy_host=proxy_url.hostname, http_proxy_port=proxy_url.port) + else: + self.sock.connect(url, header=header) self._connected = True def peek_channel(self, channel, timeout=0):