info - socket.io started Express server listening on port 3000 GET / 200 278ms - 470 GET /stylesheets/style.css 304 8ms GET /javascripts/jquery-1.7.1.min.js 304 5ms GET /javascripts/socket.io.js 304 15ms GET /javascripts/chat.js 304 25ms GET /socket.io/1/?t=1364198652158 404 2ms
app.js中是这样写的
io.sockets.on(‘connection’, function (socket) { console.log(‘connection’);
同问~有没有哪位能解答一下~
把你的app.js这个文件发上来看看,估计是把 express 和 socket.io 的 listen 的顺序搞反了。
app.listen(app.get(‘port’), function(){ console.log("Express server listening on port " + app.get(‘port’)); });
要写成 var http = require(‘http’), server = http.createServer(app) io = require(‘socket.io’).listen(server); server.listen(8080);