I am receiving an Error: xhr poll error in the connect_error event when trying to connect to my websocket gateway.
I am using "socket.io-client": "^4.2.0".
import { io } from "socket.io-client";
const ENDPOINT = "http://localhost:3001";
const socket = io(ENDPOINT);
socket.on("connect_error", (e: any) => {
console.log(e);
});
You can try to set up the client connection to use only websocket transport. By default it is using weboscket and polling.
{
transports: ['websocket']
}
So your code will become:
const socket = io(ENDPOINT, {
transports: ['websocket']
});
set server.listen instead of
app.listen
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