Socket.IO无限循环连接 [英] Socket.IO infinite loop on connection

查看:517
本文介绍了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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆