I need to use jsonp-polling for IE, and xhr-polling for Firefox, so I tried to define types of transports on the client side like this:
    if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits); 
            var socket = io.connect(VG.NODE_SERVER_URL,{ 
                    transports:['xhr-polling'] 
            }); 
    } else if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ 
            var socket = io.connect(VG.NODE_SERVER_URL,{ 
                    transports:['jsonp-polling'] 
            }); 
    } else { 
            var socket = io.connect(VG.NODE_SERVER_URL); 
    }
I tested it on Firefox and added logging on socket.io-client lib. At
https://github.com/LearnBoost/socket.io-client/blob/master/dist/socket.io.js#L1509
the option.transports is ["xhr-polling", "flashsocket", "htmlfile", 
"xhr-polling", "jsonp-polling"], which is right. However, at 
https://github.com/LearnBoost/socket.io-client/blob/master/dist/socket.io.js#L1679
I do not know why the transports change to ["htmlfile", "jsonp- 
polling", "xhr-polling"], which has the same sequence as what I 
defined on server side.
Why doesn't it use the previous option?
The bug is now fixed in socket.io version 0.9.6, I can use this and it works fine :
socket = io.connect(HOST_REMOTE, {
    transports: ['xhr-polling']
});
In version 1.0.0 and above:
socket = io.connect(HOST_REMOTE, {
    transports: ['polling']
});
there is a bug in socket.io.client.
so you can not set transports in client...
function Socket (options) {
this.options = {
    port: 80
  , secure: false
....
};
io.util.merge(this.options, options);
....
};
should be io.util.merge(this.options, options,0);....
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