Socket.io: How do I Restrict a Client to only use WebSockets as the only transport?

Created on 6 Sep 2014  路  3Comments  路  Source: socketio/socket.io

I am trying to scale a socket.io process to multiple dynos on Heroku which doesn't offer sticky-session routing and wanted to get around this issue by using WebSockets as the only transport. Is there any way to do this with 1.1? Also curious if anyone has any information on what the downsides of doing this would be other than losing browser compatibility?

Most helpful comment

AFAIK IE8 and IE9 won't be able to use websockets.
To force your client to use only websocket, in your client code you could use something like:

io.connect("http://your.domain.com", {transports: ['websocket']});

All 3 comments

AFAIK IE8 and IE9 won't be able to use websockets.
To force your client to use only websocket, in your client code you could use something like:

io.connect("http://your.domain.com", {transports: ['websocket']});

Seems like this will still falllback to using other transports if the Websocket connection fails (or perhaps it tries to use other connection methods first)

@distracteddev it shouldn't be using any other transports when using {transports: ['websocket']}. Does something (like debug output) seem to indicate otherwise?

You should probably limit the transports to only the WebSocket transport on the server too, if your connections will work with them only.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

karmac2015 picture karmac2015  路  3Comments

chfeizy picture chfeizy  路  3Comments

doughsay picture doughsay  路  4Comments

kootoopas picture kootoopas  路  4Comments

varHarrie picture varHarrie  路  3Comments