Phantomjs 2.0 SocketIO每个连接需要1000毫秒

我使用PhantomJS 2.0并试图在PhantomJS和NodeJS之间testingsocket.io。 它的工作原理,但每个连接需要大量的时间(约1000毫秒)。 我曾在Chrome上试过,它只需要1-2ms。 看来PhantomJS的page.evaluate中的socket.io不是socket.io! 这是我使用CasperJS的testing代码:

var casper = require('casper').create({ clientScripts:["socket.io.js"] }); casper.start('http://localhost:8080'); casper.page.onConsoleMessage = function(msg) { console.log(msg); }; }; casper.then(function(){ this.evaluate(function(){ var socket = io.connect('http://localhost:8080'); socket.on('news', function (data) { socket.emit('senddata', { time: new Date().getTime() }); }); }) }) casper.wait(5000); casper.run(); 

在NodeJS服务器上,我使用下面的代码:

 var app = require('http').createServer(handler) var io = require('socket.io')(app); var fs = require('fs'); app.listen(8080); function handler (req, res) { fs.readFile(__dirname + '/index.html', function (err, data) { if (err) { res.writeHead(500); return res.end('Error loading index.html'); } res.writeHead(200); res.end(data); }); } io.on('connection', function (socket) { socket.emit('news', { hello: 'world' }); socket.on('senddata', function (data) { console.log(new Date().getTime()-data.time); }); }); 

时间测量的结果总是> = 1000ms。 我需要在几毫秒内传输数据。 谁能帮我。 谢谢