Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions pybit/_websocket_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class _WebSocketManager:
def __init__(self, callback_function, ws_name,
test, domain="", api_key=None, api_secret=None,
ping_interval=20, ping_timeout=10, retries=10,
restart_on_error=True, trace_logging=False):
restart_on_error=True, trace_logging=False, ssl_options=None):

self.test = test
self.domain = domain
Expand Down Expand Up @@ -57,6 +57,9 @@ def __init__(self, callback_function, ws_name,
self.ping_interval = ping_interval
self.ping_timeout = ping_timeout
self.retries = retries

# Set SSL options
self.ssl_options = ssl_options

# Other optional data handling settings.
self.handle_error = restart_on_error
Expand Down Expand Up @@ -140,10 +143,17 @@ def resubscribe_to_topics():
)

# Setup the thread running WebSocketApp.
self.wst = threading.Thread(target=lambda: self.ws.run_forever(
ping_interval=self.ping_interval,
ping_timeout=self.ping_timeout
))
if self.ssl_options is None:
self.wst = threading.Thread(target=lambda: self.ws.run_forever(
ping_interval=self.ping_interval,
ping_timeout=self.ping_timeout
))
else:
self.wst = threading.Thread(target=lambda: self.ws.run_forever(
sslopt=self.ssl_options,
ping_interval=self.ping_interval,
ping_timeout=self.ping_timeout
))

# Configure as daemon; start.
self.wst.daemon = True
Expand Down