Version 0.3.5: Catch connection drop in sending master v0.3.5
authorBenjamin Braatz <bb@bbraatz.eu>
Mon, 13 May 2024 07:02:06 +0000 (09:02 +0200)
committerBenjamin Braatz <bb@bbraatz.eu>
Mon, 13 May 2024 07:02:06 +0000 (09:02 +0200)
controlpi_plugins/wsclient.py
setup.py

index cc8814520ca55e6f16a9881fb0c6cf6cfb1b7059..70acba6b97aaaeaf23a69277e43397440deb28a7 100644 (file)
@@ -182,7 +182,11 @@ class WSClient(BasePlugin):
                                                self._client, self.name)
         if translated_message is not None:
             json_message = json.dumps(translated_message)
-            await self._websocket.send(json_message)
+            try:
+                await self._websocket.send(json_message)
+            except Exception as e:
+                print(f"WSClient '{self.name}':"
+                      f" Exception in websocket send: {e}")
 
     async def run(self) -> None:
         """Connect to wsserver and process messages from it."""
@@ -236,7 +240,8 @@ class WSClient(BasePlugin):
                     assert isinstance(json_message, str)
                     await self._send(json_message)
             except Exception as e:
-                print(f"WSClient '{self.name}': Exception in connection: {e}")
+                print(f"WSClient '{self.name}':"
+                      f" Exception in websocket receive loop: {e}")
             self._websocket = None
             print(f"WSClient '{self.name}': Connection closed"
                   f" to {self.conf['url']}.")
index 9ef7c685b5283c252f38a270169f12777e988a4e..ff95fa632e5a5c377cf100b54c38c9223432b86e 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,7 @@ with open("README.md", "r") as readme_file:
 
 setuptools.setup(
     name="controlpi-wsclient",
-    version="0.3.4",
+    version="0.3.5",
     author="Graph-IT GmbH",
     author_email="info@graph-it.com",
     description="ControlPi Plugin for Websocket Clients",