Websocket handshake error does not auto fallback to polling or other transport
See original GitHub issueNote: for support questions, please use one of these channels: stackoverflow or slack
You want to:
- report a bug
- request a feature
Current behaviour
If websocket is supported by both browser and server but proxy or firewall disallow connection socket.io will stuck on handeshake failure forever, although polling is enabled on both side and would work without any problem.
Steps to reproduce (if the current behaviour is a bug)
Disallow websocket ws
and wss
connection in firewall and test, client will stuck on trying to connect via websocket.
Or do following in server side code:
const io = require('socket.io')(server, { transports: [
//'websocket',
'flashsocket',
'htmlfile',
'xhr-polling',
'jsonp-polling',
'polling'
] });
And Client side code:
var socket = io(window.location.protocol + "//" + window.location.hostname.split(":")[0] + ":8443", { path: "/socket.io", transports: [
'websocket',
'flashsocket',
'htmlfile',
'xhr-polling',
'jsonp-polling',
'polling
],
allowUpgrades: true
});
Theoretically client should fail a few times and switch to any of the 'flashsocket'
, 'htmlfile'
, 'xhr-polling'
, 'jsonp-polling'
, 'polling'
and work just fine.
But instead client keep on trying to connect via websocket.
Expected behaviour
After timeout or certain number of tries go back to polling or any other possible transport.
Setup
- OS: Windows Server 2012 R2
- browser: Chrome Version 54.0.2840.71 m (64-bit)
- socket.io version: 1.5.0
Other information (e.g. stacktraces, related issues, suggestions how to fix)
Supply options to set limit on upgrade attempts or retries.
This behavior is very annoying since nobody can ensure the internet infrastructure in between can always support websocket while both server and client can do/allow websocket, e.g enterprise firewall and so on.
Issue Analytics
- State:
- Created 7 years ago
- Comments:14 (6 by maintainers)
Top GitHub Comments
I think it might want to do round-robin in a specific order? Or try a few times before switch to another transportation method? Well, that is another story then. So the first method in transportations array is the default method, got it.
Nice one guys, I will try and look at fixing my problem in a similar way.