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

add ws permessage-deflate extension args for websockets 10.0 #221

Open
wants to merge 1 commit 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
5 changes: 4 additions & 1 deletion td/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

import websockets

from websockets.extensions.permessage_deflate import ClientPerMessageDeflateFactory

from td.enums import CSV_FIELD_KEYS
from td.enums import CSV_FIELD_KEYS_LEVEL_2
from td.enums import STREAM_FIELD_IDS
Expand Down Expand Up @@ -56,6 +58,7 @@ def __init__(self, websocket_url: str, user_principal_data: dict, credentials: d
"""

self.websocket_url = "wss://{}/ws".format(websocket_url)
self.websocket_args = {"extensions": [ClientPerMessageDeflateFactory()]}
self.credentials = credentials
self.user_principal_data = user_principal_data
self.connection: websockets.WebSocketClientProtocol = None
Expand Down Expand Up @@ -628,7 +631,7 @@ async def _connect(self) -> websockets.WebSocketClientProtocol:
login_request = self._build_login_request()

# Create a connection.
self.connection = await websockets.client.connect(self.websocket_url)
self.connection = await websockets.connect(self.websocket_url, **self.websocket_args)

# See if we are connected.
is_connected = await self._check_connection()
Expand Down