Search code examples
websocketiosocket.io

Socket.IO infinite loop on connection


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');
});

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);

Client-Side

var socket = io();

Solution

  • 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