From b5bd526a117a813d14b8f6b061cb7f968cda3080 Mon Sep 17 00:00:00 2001 From: onee-only Date: Mon, 30 Dec 2024 04:25:58 +0000 Subject: [PATCH] =?UTF-8?q?client=20state=20disconnected=EC=9D=BC=20?= =?UTF-8?q?=EB=95=8C=20send=20=EA=B8=88=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conn/internal/conn.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/conn/internal/conn.py b/conn/internal/conn.py index 99fa28f..90ab6a8 100644 --- a/conn/internal/conn.py +++ b/conn/internal/conn.py @@ -1,4 +1,4 @@ -from fastapi.websockets import WebSocket +from fastapi.websockets import WebSocket, WebSocketState from websockets.exceptions import ConnectionClosed from message import Message from dataclasses import dataclass @@ -23,6 +23,9 @@ async def receive(self): return Message.from_str(await self.conn.receive_text()) async def send(self, msg: Message): + if self.conn.client_state == WebSocketState.DISCONNECTED: + return + try: await self.conn.send_text(msg.to_str()) except ConnectionClosed: