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 cd2d2e8
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 @@ -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):
'''
Expand Down

0 comments on commit cd2d2e8

Please sign in to comment.