Skip to content

Commit

Permalink
Allow configuring underlying aiohttp websocket
Browse files Browse the repository at this point in the history
  • Loading branch information
bruce-y committed Oct 25, 2022
1 parent 79cd921 commit 67e8b58
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
14 changes: 11 additions & 3 deletions src/engineio/asyncio_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,20 @@ async def _connect_websocket(self, url, headers, engineio_path):
ssl_context.verify_mode = ssl.CERT_NONE
ws = await self.http.ws_connect(
websocket_url + self._get_url_timestamp(),
headers=headers, ssl=ssl_context,
timeout=self.request_timeout)
**{
**self.websocket_options,
"headers": headers,
"ssl": ssl_context,
"timeout": self.request_timeout,
})
else:
ws = await self.http.ws_connect(
websocket_url + self._get_url_timestamp(),
headers=headers, timeout=self.request_timeout)
**{
**self.websocket_options,
"headers": headers,
"timeout": self.request_timeout,
})
except (aiohttp.client_exceptions.WSServerHandshakeError,
aiohttp.client_exceptions.ServerConnectionError,
aiohttp.client_exceptions.ClientConnectionError):
Expand Down
4 changes: 3 additions & 1 deletion src/engineio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ class Client(object):
event_names = ['connect', 'disconnect', 'message']

def __init__(self, logger=False, json=None, request_timeout=5,
http_session=None, ssl_verify=True, handle_sigint=True):
http_session=None, ssl_verify=True, handle_sigint=True,
websocket_options={}):
global original_signal_handler
if handle_sigint and original_signal_handler is None and \
threading.current_thread() == threading.main_thread():
Expand All @@ -97,6 +98,7 @@ def __init__(self, logger=False, json=None, request_timeout=5,
self.queue = None
self.state = 'disconnected'
self.ssl_verify = ssl_verify
self.websocket_options = websocket_options

if json is not None:
packet.Packet.json = json
Expand Down

0 comments on commit 67e8b58

Please sign in to comment.