From fbaef1b48e0d58e5aed34bffbb873dd4ed60c17d Mon Sep 17 00:00:00 2001 From: Shane McMaster Date: Sat, 27 Jan 2024 13:52:16 +1300 Subject: [PATCH 1/2] change ws_client to use libraries reconnect param --- jellyfin_kodi/jellyfin/ws_client.py | 16 ++++------------ release.yaml | 2 +- requirements-dev.txt | 2 +- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/jellyfin_kodi/jellyfin/ws_client.py b/jellyfin_kodi/jellyfin/ws_client.py index 3a9ce122..744abbed 100644 --- a/jellyfin_kodi/jellyfin/ws_client.py +++ b/jellyfin_kodi/jellyfin/ws_client.py @@ -35,7 +35,6 @@ class WSClient(threading.Thread): self.client = client threading.Thread.__init__(self) - self.retry_count = 0 def send(self, message, data=""): @@ -62,23 +61,18 @@ class WSClient(threading.Thread): while not self.stop: - time.sleep(self.retry_count * 5) - self.wsc.run_forever(ping_interval=10) + self.wsc.run_forever(ping_interval=10, reconnect=10) if not self.stop and monitor.waitForAbort(5): break - # Wait a maximum of 60 seconds before retrying connection - if self.retry_count < 12: - self.retry_count += 1 - - LOG.info("---<[ websocket ]") - def on_error(self, ws, error): LOG.error(error) def on_open(self, ws): - LOG.info("--->[ websocket ]") + LOG.info("--->[ websocket opened ]") + # Avoid a timing issue where the capabilities are not correctly registered + time.sleep(1) if settings('remoteControl.bool'): self.client.jellyfin.post_capabilities({ 'PlayableMediaTypes': "Audio,Video", @@ -99,8 +93,6 @@ class WSClient(threading.Thread): "PlayableMediaTypes": "Audio, Video", "SupportsMediaControl": False }) - # Reinitialize the retry counter after successful connection - self.retry_count = 0 def on_message(self, ws, message): diff --git a/release.yaml b/release.yaml index 1ac0cb1c..e3c791a5 100644 --- a/release.yaml +++ b/release.yaml @@ -34,4 +34,4 @@ dependencies: - addon: 'script.module.addon.signals' version: '0.0.5+matrix.1' - addon: 'script.module.websocket' - version: '0.58.0+matrix.1' + version: '1.6.4' diff --git a/requirements-dev.txt b/requirements-dev.txt index d8dcb12e..eb1838b6 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -16,7 +16,7 @@ pytest >= 4.6.11 coverage >= 5.2 flake8 >= 3.8 flake8-import-order >= 0.18 -websocket-client >= 0.57.0 +websocket-client >= 1.6.4 types-requests >= 2.31 types-PyYAML >= 6.0 From 3d24ca8af967101baccdaea55ed86fd0b72f4829 Mon Sep 17 00:00:00 2001 From: Shane McMaster Date: Tue, 6 Feb 2024 10:44:49 +1300 Subject: [PATCH 2/2] adjust capability delay to 5s --- jellyfin_kodi/jellyfin/ws_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jellyfin_kodi/jellyfin/ws_client.py b/jellyfin_kodi/jellyfin/ws_client.py index 744abbed..65da191e 100644 --- a/jellyfin_kodi/jellyfin/ws_client.py +++ b/jellyfin_kodi/jellyfin/ws_client.py @@ -72,7 +72,7 @@ class WSClient(threading.Thread): def on_open(self, ws): LOG.info("--->[ websocket opened ]") # Avoid a timing issue where the capabilities are not correctly registered - time.sleep(1) + time.sleep(5) if settings('remoteControl.bool'): self.client.jellyfin.post_capabilities({ 'PlayableMediaTypes': "Audio,Video",