持续http://localhost:8890/socket.io/?EIO=3&transport=polling&t=1525342978802-2获取请求
客户端:socket = io.connect('http://localhost:8890')
服务器:var app = require('express')();
var server = require('http')。服务器(app);
var io = require('socket.io')(服务器); server.listen(8890);
io.on('connection',function(socket){
console.log(socket['id'] + " client connected");
});
任何帮助高度赞赏。提前致谢。
答案 0 :(得分:1)
假设您从这些调用中收到404错误,请注意以下两点:
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.4/socket.io.js"></script>
或者只是
<script src="/socket.io/socket.io.js"></script>
您可以编写完整的代码(至少是客户端)吗?