import asyncio from websockets.asyncio.client import connect import websockets async def init(): uri = "ws://192.168.6.101:3003" async with connect(uri) as websocket: await websocket.send("status") while True: try: msg = await websocket.recv() print(msg) except websockets.ConnectionClosed: print(f"Terminated by server") break except asyncio.exceptions.CancelledError: print("Closed by user") break if __name__ == "__main__": asyncio.run(init())