I'm having some weird issues with socket.io and modern browsers. Surprisingly, IE9 works just fine because backing up to flashsocket seems to work better.
On 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' ]); });
In the browser, I see on the "Network" tab (in Chrome) that websocket is installed and enters the 101 Switching Protocols
in standby mode. After that, xhr polling and jsonp polling appear (what happened with flashsocket?)
The worst part is that the information does not go back and forth. I have this when connecting:
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 the client:
socket.on('currentStatus', function (data){ console.log(data) });
However, I can see this log only when the server is turned off, which starts with:
NODE_ENV=production node server.js
What am I doing wrong?
source share