From 54e5591a1c3200f52ceb611d22444dc855780776 Mon Sep 17 00:00:00 2001 From: Caleb Collins-Parks <46505081+caleb15@users.noreply.github.com> Date: Fri, 19 Aug 2022 09:41:38 -0700 Subject: [PATCH] Default code to 1005 See https://github.com/django/asgiref/issues/340 --- channels/generic/websocket.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/channels/generic/websocket.py b/channels/generic/websocket.py index 6c8ca5769..cacdf3516 100644 --- a/channels/generic/websocket.py +++ b/channels/generic/websocket.py @@ -102,7 +102,7 @@ def websocket_disconnect(self, message): raise InvalidChannelLayerError( "BACKEND is unconfigured or doesn't support groups" ) - self.disconnect(message["code"]) + self.disconnect(message.get("code", 1005)) raise StopConsumer() def disconnect(self, code): @@ -235,7 +235,7 @@ async def websocket_disconnect(self, message): raise InvalidChannelLayerError( "BACKEND is unconfigured or doesn't support groups" ) - await self.disconnect(message["code"]) + await self.disconnect(message.get("code", 1005)) raise StopConsumer() async def disconnect(self, code):