Is it possible connect to socket.io server with standard web-socket client? When connecting to socket.io server through socket.io client, Url started with HTTP but for web-socket clients must use ws. so, if it is possible, how to connect to socket.io server and what is the url for connecting to socket.io server?
Although Socket.IO indeed uses WebSocket as a transport when possible, it adds additional metadata to each packet. 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 plain WebSocket server either.
You need to pass your server there, not the http module and you need to assign the result to an io variable. So, after you've defined and initialized your server variable, you would do: const io = require("socket.io")(server);
socket.io
has a protocol on top of webSockets. If you're going to use socket.io
on the server side, then you have to use a socket.io-compatible client on the other end.
So, you can't use a plain webSocket client to connect to a socket.io server.
The socket.io protocol is here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With