5

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);
2
  • Are you sure it is actually get blocked? Looks like you have error here - listen server before attaching socket.io might work wrong. Refer to example here: socket.io/#how-to-use As well, socket.io will try to use WebSockets and they are well just HTTP initially, so firewall cant usually identify them. Why you think it is Firewall and not something else? Please post more data and exactly why you think it is blocked.
    – moka
    Sep 17, 2013 at 14:41
  • It is firewall blocking stuff because I see no errors and yes I changed the code to attach socket first.
    – user883499
    Sep 18, 2013 at 8:20

1 Answer 1

6

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

3
  • When I use xhr-polling only, I am not able to get real time updates for some reason. And because of this the user would need to refresh the page to see the latest changes. With websockets I am able to achieve real time updates.
    – user883499
    Sep 18, 2013 at 12:21
  • That's odd, xhr-polling and websocket should behave the same way. Can you verify that XHR connections are correctly established in the console ? Sep 18, 2013 at 12:30
  • It works perfectly as expected on localhost, but does not work as expected when I deploy to remote box on ec2 (EBS).
    – user883499
    Sep 18, 2013 at 13:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.