Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions channels/generic/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!")

Expand Down Expand Up @@ -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!")

Expand Down