Open hassansin opened 9 months ago
Hi!
The order in the transports
option matters:
const socket = io("https://example.com", {
transports: ["websocket", "polling"] // use WebSocket first, if available
});
socket.on("connect_error", () => {
// revert to classic upgrade
socket.io.opts.transports = ["polling", "websocket"];
});
Reference: https://socket.io/docs/v4/client-options/#transports
@darrachequesne okay, so if Websocket is blocked by proxy and unable to connect, shouldn't it switch to polling?
Anything? What's the point of having multiple transports if automatic switching doesn't work?
Describe the bug I'm trying to connect with
websocket
transport first and if it fails I was hoping socketio would switch to long-polling. But for some reason, it keeps reconnecting withwebsocket
transport and never switches to polling.To Reproduce
Socket.IO server version:
4.7.2
Server
Socket.IO client version:
4.7.2
Client
Expected behavior Was expecting the transport would switch to long-polling when websocket isn't available.
Platform:
Additional context I disabled websocket by blocking websocket calls using the Firefox request blocking feature. Can be disabled using this TamperMonkey script as well.