Socket.IO 连接上的无限循环 [英] Socket.IO infinite loop on connection
本文介绍了Socket.IO 连接上的无限循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Socket.IO 在连接上进行无限循环!这很奇怪,直到现在才发生.我不知道怎么了.我尝试重建包,我从旧源复制了一些代码,结果相同...
Socket.IO make an infinte loop on connection ! It's weird and never happen until now. I don't know what's wrong. I try to rebuild the package, I copy some code from an older source and the same result...
io.on('connection', function(socket){
console.log('someone connected << infinite loop');
});
这是一个基本的 ExpressJS 服务器,上面有 http.
It's a basic ExpressJS server with http on top.
const
port = process.env.PORT || 3200,
app = require('express')(),
express = require('express'),
mysql = require('mysql'),
bodyParser = require('body-parser'),
path = require('path'),
methodOverride = require('method-override'),
http = require('http').Server(app),
io = require('socket.io')(http);
客户端
var socket = io();
推荐答案
问题出在客户端,我不像在服务器端那样加载最新版本的 socket.io.在我的 package.json 中,我有 2.0.3,而在客户端是 1.2.0 .. 对于遇到此问题的每个人
The problem was at the client-side, I don't load the latest version of socket.io like on the server-side. In my package.json I have 2.0.3 and at the client-side was 1.2.0.. For everyone who have this problem
这篇关于Socket.IO 连接上的无限循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文