Socket.io and modern browsers aren't working

Viewed 7365

I'm having some weird issues with socket.io and modern browsers. Surprisingly, with IE9 works fine because fallbacks to flashsocket which appears to work better.

In my server (with express)

var io = socketio.listen(server.listen(8080));
io.configure('production', function(){
    console.log("Server in production mode");
    io.enable('browser client minification');  // send minified client
    io.enable('browser client etag');          // apply etag caching logic based on version number
    io.enable('browser client gzip');          // gzip the file
    io.set('log level', 1);                    // reduce logging
    io.set('transports', [                     // enable all transports (optional if you want flashsocket)
        'websocket'
        , 'flashsocket'
        , 'htmlfile'
        , 'xhr-polling'
        , 'jsonp-polling'
    ]);
});

On the browser I can see in the Network tab (on Chrome) that a websocket is stablished and get in 101 Switching Protocols in Pending mode. After that, appears xhr-polling and jsonp-polling (what happend to flashsocket ? )

The worst part is that info don't go back and forth. I have this on connection:

io.sockets.on('connection', function (socket) {
    // If someone new comes, it will notified of the current status of the application
    console.log('Someone connected');
    app.sendCurrentStatus(socket.id);
    io.sockets.emit('currentStatus', {'connected': true);
});

And on client:

socket.on('currentStatus', function (data){ console.log(data) });

However I only be able to see that log when I turn off the server which is launched with:

NODE_ENV=production node server.js

What am I doing wrong?

2 Answers
Related