when i use socke.io at normal internet speed it works fine.But when I simulate a slow 3G in the chrome developer console.
This error is displayed:
failed: WebSocket is closed before the connection is established.
How do I configure socket.io for slow internet connection?
This is my configuration:
io("ws:xxxxx.xxxx", {
transports: ["websocket"],
upgrade: true,
path: "messenger",
query: {
token: "xxxxxxxxxx",
},
timeout: 1000,
});
note: this configuration works on a fast connection.
You're closing the socket before socketio has a chance to connect. Increase the timeout value to around 10000 (10 seconds), and that should solve your issue.