I have an issue with socket.io. When I run my code on my computer (local) I can use http://IP:120/socket.io/socket.io.js. However, on my server (Digital ocean server ubuntu 16.04) I did not see anything at this url. Where is my error? Can anyone help me? I used the createServer and Server function, but neither of them worked.
var app = require('express')();
//var http=require('http').Server(app);
var http=require('http').createServer(app);
var io=require('socket.io')(http);
app.get("/",function(req,res){
res.sendfile(__dirname+"/asd.html");
});
io.on('connection',function(socket) {
console.log("A User Connected");
});
var port=120;
http.listen(port,'ServerIP');
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…