Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Console logs "Booting Client" around 100 times, then crashes. #953

Closed
ghost opened this issue Jul 12, 2012 · 9 comments
Closed

Console logs "Booting Client" around 100 times, then crashes. #953

ghost opened this issue Jul 12, 2012 · 9 comments

Comments

@ghost
Copy link

ghost commented Jul 12, 2012

I have a bug(?) with my node.js. And I think it has something to do with socket.io. So what it does is Logging "Booting Client" around a hundred times, then it crashes with the error:

util.js:35 var str = String(f).replace(formatRegExp, function(x) { ^ RangeError: Maximum call stack size exceeded

I am guessing that the stack size is exceeded because Socket.io is doing "booting client" so many times.

@3rd-Eden
Copy link
Contributor

There is no such string as "Booting Client" in the socket.io source code

@ghost
Copy link
Author

ghost commented Jul 12, 2012

Then it might be nodejs itself... I'll repost the Issue there

@ghost ghost closed this as completed Jul 12, 2012
@ghost ghost reopened this Jul 12, 2012
@ghost
Copy link
Author

ghost commented Jul 12, 2012

I found out that it acctually does contain "booting client" under node_modules/socket.io/lib/socket.js
What proves that it is an issue with socket.io.

@ghost
Copy link
Author

ghost commented Jul 12, 2012

The code where it does that is line 290 to 310:
Socket.prototype.disconnect = function () {
if (!this.disconnected) {
this.log.info('booting client');

if ('' === this.namespace.name) {
  if (this.manager.transports[this.id] && this.manager.transports[this.id].open) {
    this.manager.transports[this.id].onForcedDisconnect();
  } else {
    this.manager.onClientDisconnect(this.id);
    this.manager.store.publish('disconnect:' + this.id);
  }
} else {
  this.packet({type: 'disconnect'});
  this.manager.onLeave(this.id, this.namespace.name);
  this.$emit('disconnect', 'booted');
}

}

return this;
};

@3rd-Eden
Copy link
Contributor

Oh good catch, it seemed that my files where out of date :p

@ghost
Copy link
Author

ghost commented Jul 12, 2012

Good, I hope we can fix this now. It really is slowing down my development.

@ghost
Copy link
Author

ghost commented Jul 12, 2012

I have an idea what it might be:
This function calls when the client disconnects doesnt it?
And in the function there is:
this.$emit('disconnect', 'booted');
and
this.manager.store.publish('disconnect:' + this.id);

Which basically(at least to my understanding) disconnect the client.

So when the function is called, it disconnects the client, what calls it again.

Also this only happens since my newest update in ym game, and I remember including the 'socket.on("disconnect"'
there... This might be it. I'll remove that event and see if it still does it once I get back to development.

@ghost
Copy link
Author

ghost commented Jul 12, 2012

Seems like it was my fault (Stupid idiot me). I had put socket.disconnect() in the socket.on("disconnect") event thinking that it would call it only once, stupid stupid me. Changed it to socket.once("disconnect") now. Sorry for wasting your time.

@ghost ghost closed this as completed Jul 12, 2012
@sivatumma
Copy link

I am kind of not satisfied with this answer. Mine is a similar issue, Help if you can find some answer...
Here is my code


var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);

io.on('connection', function(socket) {
  console.log("Client connected through 'connect' socket.io ");
  socket.emit('data',{siva:"is thumma"});

  var server = require('net').createServer(function(deviceSocket) {
    deviceSocket.on('data', function(data) {
      var decodedDeviceData = data.toString('utf8');
      console.log("Data from client", data);
      deviceSocket.emit('data',data);
      deviceSocket.emit('data', decodedDeviceData);

    });
  });
  server.listen(5062, "0.0.0.0");
});

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants