Skip to content

Commit

Permalink
server: close TCP connection after closing websocket
Browse files Browse the repository at this point in the history
Fixes #115 and #147.
  • Loading branch information
belm0 committed Feb 2, 2021
1 parent dbf819d commit 3c30418
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions trio_websocket/_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,12 @@ async def _handle_close_connection_event(self, event):
await self._send(event.response())
await self._close_web_socket(event.code, event.reason or None)
self._close_handshake.set()
# 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 _handle_message_event(self, event):
'''
Expand Down

0 comments on commit 3c30418

Please sign in to comment.