From d78b955ab303316b96e993ad777b679088bb0d47 Mon Sep 17 00:00:00 2001 From: Someone Date: Mon, 22 Mar 2021 20:35:10 +0100 Subject: [PATCH] Websocket workaround for broken MM: https://github.com/mattermost/mattermost-server/issues/17197 --- mattermost/version.py | 2 +- mattermost/ws.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/mattermost/version.py b/mattermost/version.py index 35b262f..a521e14 100755 --- a/mattermost/version.py +++ b/mattermost/version.py @@ -6,4 +6,4 @@ Someone's Mattermost API v4 bindings. """ # Set this package's version. -__version__ = "5.31.0" +__version__ = "5.33.0" diff --git a/mattermost/ws.py b/mattermost/ws.py index 9c06653..e5097f2 100644 --- a/mattermost/ws.py +++ b/mattermost/ws.py @@ -60,9 +60,10 @@ class MMws: async def _websocket_run(self): logger.info("Starting websocket client.") - async with websockets.connect(self.ws_url) as websocket: - await websocket.send(json.dumps({"seq": 1, "action":"authentication_challenge", "data":{"token":self.api._bearer}})) - logger.info("websocket client connected") + async with websockets.connect(self.ws_url, ping_interval=None, extra_headers={"Authorization": "Bearer "+self.api._bearer}) as websocket: + #await websocket.send(json.dumps({"seq": 1, "action":"authentication_challenge", "data":{"token":self.api._bearer}})) + logger.info(json.loads(await websocket.recv())) + logger.info("websocket client connected. looping...") while self.loop: data = json.loads(await websocket.recv()) -- 2.43.0