diff --git a/channels/generic/websocket.py b/channels/generic/websocket.py index 8cc8d1636..e0ccba4fe 100644 --- a/channels/generic/websocket.py +++ b/channels/generic/websocket.py @@ -123,6 +123,8 @@ class JsonWebsocketConsumer(WebsocketConsumer): def receive(self, text_data=None, bytes_data=None, **kwargs): if text_data: self.receive_json(self.decode_json(text_data), **kwargs) + elif not text_data and bytes_data: + raise ValueError("No text section for incoming WebSocket frame! There is a bytes section, however. Did you mean for it to be the text section?") else: raise ValueError("No text section for incoming WebSocket frame!") @@ -257,6 +259,8 @@ class AsyncJsonWebsocketConsumer(AsyncWebsocketConsumer): async def receive(self, text_data=None, bytes_data=None, **kwargs): if text_data: await self.receive_json(await self.decode_json(text_data), **kwargs) + elif not text_data and bytes_data: + raise ValueError("No text section for incoming WebSocket frame! There is a bytes section, however. Did you mean for it to be the text section?") else: raise ValueError("No text section for incoming WebSocket frame!")