socket.io と最新のブラウザーで奇妙な問題が発生しています。驚いたことに、IE9 では flashsocket へのフォールバックの方が適切に動作するように見えるため、正常に動作します。
私のサーバーで(エクスプレスで)
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'
]);
});
ブラウザの [ネットワーク] タブ (Chrome) で、Websocket が確立され101 Switching Protocols
、保留モードになっていることがわかります。その後、xhr-polling と jsonp-polling が表示されます (flashsocket はどうなりましたか?)
最悪の部分は、情報が行き来しないことです。私はこれを接続しています:
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);
});
そしてクライアント上で:
socket.on('currentStatus', function (data){ console.log(data) });
ただし、次のように起動したサーバーの電源を切ると、そのログしか表示されません。
NODE_ENV=production node server.js
私は何を間違っていますか?