求助,socket.IO连接失败,
发布于 7 年前 作者 mengrpg1 6689 次浏览 最后一次编辑是 3 年前

下面是错误代码: 首次连接 38iNY3W1tJjFJ-zZQtZE 的客户端. debug - setting request GET /socket.io/1/xhr-polling/38iNY3W1tJjFJ-zZQtZE?t=1 362482135950 debug - setting poll timeout debug - discarding transport debug - cleared heartbeat interval for client 38iNY3W1tJjFJ-zZQtZE debug - setting request GET /socket.io/1/jsonp-polling/38iNY3W1tJjFJ-zZQtZE?t =1362482145953&i=0 debug - setting poll timeout debug - discarding transport debug - clearing poll timeout debug - clearing poll timeout debug - jsonppolling writing io.j0; debug - set close timeout for client 38iNY3W1tJjFJ-zZQtZE debug - jsonppolling closed due to exceeded duration debug - setting request GET /socket.io/1/jsonp-polling/38iNY3W1tJjFJ-zZQtZE?t =1362482165976&i=0 debug - setting poll timeout debug - discarding transport

3 回复

一直是这个样子,我服务端的代码是 var server =http.createServer(app).listen(app.get(‘port’), function() { console.log("Express server listening on port " + app.get(‘port’)); console.log(“服务器已经通过:” + app.get(‘port’) + “端口启动…”); });

var sio= require(‘socket.io’); var io = sio.listen(server); var conns = {}; io.sockets.on(‘connection’, function(socket) { console.log(“首次连接 " + socket.id + " 的客户端.”);

socket.on('message', function(message){
    console.log("客户端的消息: " + message + " -来自" + socket.id);
});
socket.on('disconnect', function(){
    console.log("客户端 " + socket.id + " 终止.");
});

我发现原因了,是我安装 socket.io时出错了,我当时用socket没报错以为可以忽略,o(︶︿︶)o 唉

具体是什么错?

回到顶部