react-use-websocket icon indicating copy to clipboard operation
react-use-websocket copied to clipboard

update to Socket.IO v4.x

Open olegtaranenko opened this issue 2 years ago • 1 comments

Using last version of socket.io 4.x cause exception in browser:

create-or-join.ts:63 WebSocket connection to 'ws://localhost:3003/socket.io/?EIO=3&transport=websocket' failed: Invalid frame header

Which is usually means socket server/client version mismatch.

To workaround need to downgrade server library to

"socket.io": "3.1.2",

olegtaranenko avatar Jun 12 '22 10:06 olegtaranenko

On the server side, you should include allowEIO3 in your socketIO options.

For example:

const io = new Server({
  allowEIO3: true,
});

This will fix the headers.

McJezuss avatar Jan 13 '24 13:01 McJezuss