socket.io轮询404错误

我尝试在我的Web服务器上学习socket.io。 我在我的服务器上安装了node.js和socket.io。 我已经准备好了网站我的套接字javascript代码工作正常 – 在控制台上听听端口3000 – 但是当我尝试运行示例聊天应用程序时,我得到了“socket.io/?EIO=3&transport=polling&t=1423949334574-31 404(Not Found )“错误。 哪里错了?

var app = require('express')(); var http = require('http').Server(app); var io = require('socket.io')(http); app.get('/', function(req, res){ res.sendFile(__dirname + '/index.html'); }); io.on('connection', function(socket){ socket.on('chat message', function(msg){ io.emit('chat message', msg); }); }); http.listen(3000, function(){ console.log('listening on *:3000'); }); 

有我的index.html脚本:

 <script> var socket = io("http://localhost:3000"); $('form').submit(function(){ socket.emit('chat message', $('#messagebox').val()); var mesaj = $('#messagebox').val(); $('.messageBoard').prepend('<p style="display: none">'+mesaj+'</p>'); $('#messagebox').val(''); $('.messageBoard').find('p:first-child').show('slideDown'); e.preventDefault(); return false; }); socket.on('chat message', function(msg){ $('.messageBoard').prepend('<p style="display: none">'+mesaj+'</p>'); }); </script>