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

User-defined SSL options #79

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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