From cd9018be40b040090e4dfd1fa17bf2532365a07f Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Sat, 29 Oct 2022 21:23:22 +0200 Subject: [PATCH] Update uvicorn/protocols/websockets/wsproto_impl.py Co-authored-by: Tom Christie --- uvicorn/protocols/websockets/wsproto_impl.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/uvicorn/protocols/websockets/wsproto_impl.py b/uvicorn/protocols/websockets/wsproto_impl.py index 35f88a720..bc9651fe7 100644 --- a/uvicorn/protocols/websockets/wsproto_impl.py +++ b/uvicorn/protocols/websockets/wsproto_impl.py @@ -91,7 +91,9 @@ def data_received(self, data): self.transport.write(self.conn.send(err.event_hint)) self.transport.close() else: - self.handle_no_connect(events.CloseConnection(code=1007)) + # Response with the "1002 Protocol Error" code. + # See https://www.iana.org/assignments/websocket/websocket.xhtml#close-code-number + self.handle_no_connect(events.CloseConnection(code=1002)) else: self.handle_events()