diff --git a/trio_websocket/_impl.py b/trio_websocket/_impl.py index 36d6cbf..3aceda6 100644 --- a/trio_websocket/_impl.py +++ b/trio_websocket/_impl.py @@ -1018,6 +1018,12 @@ async def _close_web_socket(self, code, reason=None): exc = ConnectionClosed(self._close_reason) logger.debug('%s websocket closed %r', self, exc) await self._send_channel.aclose() + # RFC: "When a server is instructed to Close the WebSocket Connection + # it SHOULD initiate a TCP Close immediately, and when a client is + # instructed to do the same, it SHOULD wait for a TCP Close from the + # server." + if self.is_server: + await self._close_stream() async def _get_request(self): '''