Socket.io 1.0,IE7。 无法读取发出的消息

尝试从服务器读取发出的消息。 IE7似乎失败..

服务器代码:

服务器每半秒发出一次“消息”,发出二十条消息后断开

var server = require('http').createServer(); var io = require('socket.io')(server,{ 'transports':[ 'polling', 'websocket', 'flashsocket', 'htmlfile' ] }); io.on('connection', function (socket) { console.log('connect: '+socket.id); var num = 0; var cInterval = setInterval(function(){ console.log(num+' emit news'); socket.emit('news', 'this is news '+num); num++; if(num==20) socket.disconnect(); },500); socket.on('disconnect', function(why){ console.log('disconnect: '+socket.id); clearInterval(cInterval); }); }); server.listen(port,ip); console.log('io ready'); 

客户代码:

客户端将logging连接尝试,新闻内容和断开事件。

 var socket = io('ws://localhost:8080') .on('connect',function(){ logging('connecting'); }) .on('disconnect',function(){ logging('disconnected'); }) .on('news', function (data) { logging(data); }); 

我没有使用console.log作为日志logging机制,所以IE7应该没问题。

导致IE8,IE9,Chrome:

 connecting this is news 0 this is news 1 ... this is news 19 disconnected 

导致IE7:

 connecting disconnected 

这是已知的吗?

有什么解决方法吗?

任何帮助将不胜感激..谢谢..

使用JSON2,因为IE7没有原生的JSON对象。 http://cdnjs.cloudflare.com/ajax/libs/json2/20130526/json2.min.js