Skip to content

Commit

Permalink
Close websocket with 1011 on internal error (1006 is a client-only code)
Browse files Browse the repository at this point in the history
  • Loading branch information
samsamoa authored and pgjones committed Jul 8, 2023
1 parent ebd5b72 commit 46575fe
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/hypercorn/protocol/ws_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ async def app_send(self, message: Optional[ASGISendEvent]) -> None:
self.scope, {"status": 500, "headers": []}, time() - self.start_time
)
elif self.state == ASGIWebsocketState.CONNECTED:
await self._send_wsproto_event(CloseConnection(code=CloseReason.ABNORMAL_CLOSURE))
await self._send_wsproto_event(CloseConnection(code=CloseReason.INTERNAL_ERROR))
await self.send(StreamClosed(stream_id=self.stream_id))
else:
if message["type"] == "websocket.accept" and self.state == ASGIWebsocketState.HANDSHAKE:
Expand Down

0 comments on commit 46575fe

Please sign in to comment.