diff --git a/hbd b/hbd index 36621d0..4e19e8e 100755 --- a/hbd +++ b/hbd @@ -864,13 +864,17 @@ def websocketupdater(): def msg_to_websockets(typ: str, msg: str): jmsg = json.dumps({'type': typ, 'data': msg}) + to_close = [] for ws in ws_connections: try: asyncio.run(ws.send(jmsg)) - except Exception as e: - print("ws.send exception: %s" % e) - exit(1) + except Exception: + to_close.append(ws) + print("ws.send exception: closed") + for ws in to_close: + ws.close() + del ws_connections[ws] # # Main # diff --git a/wstest.py b/wstest.py index 88cfdd3..4b7743b 100644 --- a/wstest.py +++ b/wstest.py @@ -2,7 +2,7 @@ import asyncio import websockets async def hello(): - uri = "ws://w02:50005/messages" + uri = "ws://localhost:50005/messages" async with websockets.connect(uri) as websocket: name = "Andreas"