[Fixed]-Django channels and socket.io-client

16👍

From the Socket.IO README:

Note: Socket.IO is not a WebSocket implementation. Although Socket.IO indeed uses WebSocket as a transport when possible, it adds some metadata to each packet: the packet type, the namespace and the ack id when a message acknowledgement is needed. That is why a WebSocket client will not be able to successfully connect to a Socket.IO server, and a Socket.IO client will not be able to connect to a WebSocket server (like ws://echo.websocket.org) either. Please see the protocol specification here.

So, you shouldn’t expect Channels to work directly with Socket.IO. Global browser support for websockets is at 93%, which is probably high enough to just use the websocket API directly.

8👍

To quote the creator of django channels: https://github.com/django/channels/issues/1038

Channels doesn’t support socket.io – it’s a different protocol that isn’t websockets or HTTP but layers on top of them. You’ll have to use a socket.io server if you want to use it.

Leave a comment