SocketIO- GET http://localhost:3000/socket.io/?EIO=3&transport=polling&t=1418187395022-0 404

If you're running Express 4, it appears to me like you're missing the lines of code:

var app = express(); var server = app.listen(3000); 

That will start your web server and set it to port 3000. See the bone simple Express 4 app here: http://expressjs.com/4x/api.html

And, then to start up socket.io, you would add:

var io = require('socket.io').listen(server); 

And, there is no need for this line:

var http = require('http'); 

原文地址:https://www.e-learn.cn/content/wangluowenzhang/160555

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章