diff options
Diffstat (limited to 'kvmd')
-rw-r--r-- | kvmd/apps/vnc/server.py | 2 | ||||
-rw-r--r-- | kvmd/clients/kvmd.py | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/kvmd/apps/vnc/server.py b/kvmd/apps/vnc/server.py index 05e4ae66..49d0c81f 100644 --- a/kvmd/apps/vnc/server.py +++ b/kvmd/apps/vnc/server.py @@ -166,7 +166,7 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes self.__stage3_ws_connected.set_passed() async for event in self.__kvmd_ws.communicate(): await self.__process_ws_event(event) - raise RfbError("KVMD closes the websocket (the server may have been stopped)") + raise RfbError("KVMD closed the websocket (the server may have been stopped)") finally: self.__kvmd_ws = None diff --git a/kvmd/clients/kvmd.py b/kvmd/clients/kvmd.py index 84576fb2..b4585bcc 100644 --- a/kvmd/clients/kvmd.py +++ b/kvmd/clients/kvmd.py @@ -153,6 +153,8 @@ class KvmdClientWs: msg = receive_task.result() if msg.type == aiohttp.WSMsgType.TEXT: yield json.loads(msg.data) + elif msg.type == aiohttp.WSMsgType.CLOSE: + await self.__ws.close() elif msg.type == aiohttp.WSMsgType.CLOSED: break else: @@ -167,6 +169,10 @@ class KvmdClientWs: receive_task.cancel() if writer_task: writer_task.cancel() + try: + await self.__ws.close() + except Exception: + pass self.__communicated = False async def send_key_event(self, key: str, state: bool) -> None: |