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

varHarrie picture varHarrie  ·  3Comments

stnwk picture stnwk  ·  4Comments

thebinarypenguin picture thebinarypenguin  ·  4Comments

MichaelJCole picture MichaelJCole  ·  3Comments

renkei picture renkei  ·  4Comments