Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Socket IO WebSocket requests blocked by corporate firewalls.

What is the solution to using socket.io module from behind corporate firewall/proxy? This is the code I am using.

// setup express server
var app = express()
var serv = http.createServer(app);
serv.listen(80);

// setup socket io - listens in on express store as well for sessions
var io = require('socket.io').listen(serv);
like image 536
user883499 Avatar asked Sep 17 '13 14:09

user883499


1 Answers

I had a similar issue and I ended up disabling websocket entirely:

io.configure('production', function(){
  io.set('transports', ['xhr-polling']);
});

XHR-polling works everywhere, but has a much bigger overhead for everyone (even if only 5% of users actually need it).

Good news is, the upcoming 1.0 version of Socket.IO will fix this:

Unlike the previous Socket.IO core, it always establishes a long-polling connection first, then tries to upgrade to better transports that are "tested" on the side.

Check it here: https://github.com/LearnBoost/engine.io

like image 95
Laurent Perrin Avatar answered Oct 04 '22 20:10

Laurent Perrin