diff --git a/trio_websocket/_impl.py b/trio_websocket/_impl.py index 188e2bf..30e1c19 100644 --- a/trio_websocket/_impl.py +++ b/trio_websocket/_impl.py @@ -1495,7 +1495,8 @@ async def _handle_ping_event(self, event: wsproto.events.Ping) -> None: :param wsproto.events.Ping event: ''' logger.debug('%s ping %r', self, event.payload) - await self._send(event.response()) + if self._wsproto.state != ConnectionState.LOCAL_CLOSING: + await self._send(event.response()) async def _handle_pong_event(self, event: wsproto.events.Pong) -> None: '''