wzrdtales / socket-io-sticky-session

Sticky session balancer with layer 4 capabilities, based on a `cluster` module
72 stars 21 forks source link

Restart server multiple times and don´t send response #21

Open urieluvd opened 8 years ago

urieluvd commented 8 years ago

Node v6.6.0, Socket-io-sticky-session 0.4.2 Windows 10 64-bit

I have a script with multiple socket.io instances

const express = require('express');
const app = express();
const http = require('http').Server(app);
const http2 = require('http').Server();

const io = require('socket.io')(http);
const io2 = require('socket.io')(http2);

const redis = require('socket.io-redis');
io.adapter(redis({ host: 'localhost', port: 6379 }));
io2.adapter(redis({ host: 'localhost', port: 6379 }));

var exports = module.exports = {
  http:http,
  http2:http2
};

I use them as a module to run them with cluster

const cluster = require('cluster');
const numCPUs = require('os').cpus().length;
const sticky = require('socketio-sticky-session');
const connectionServer = require('./usersConnection');

if (cluster.isMaster) {

  for (var i = 0; i < numCPUs; i++) {
    cluster.fork();
  }

  cluster.on('exit', (worker, code, signal) => {
    console.log(`worker ${worker.process.pid} died`);
  });

} else {
    connectionServer.http.listen(3001, function(){
          console.log('Listening on Port 3001');
        });

    connectionServer.http2.listen(3002, function(){
      console.log('Listening on Port 3002');
    }); 
}

This works fine. But when I try to use sticky session it restarts over and over until it throws this \nodejs\node.exe: c:\ws\src\stream_base.h:217: Assertion(consumed_) == (false)' failed.`

I used the basic example

sticky(connectionServer.http).listen(3001, function() {
  console.log('server started on 3001 port');
});

sticky(connectionServer.http2).listen(3002, function() {
  console.log('server started on 3002 port');
});

Is my implementation wrong?

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/38209022-restart-server-multiple-times-and-don-t-send-response?utm_campaign=plugin&utm_content=tracker%2F10408799&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F10408799&utm_medium=issues&utm_source=github).
wzrdtales commented 8 years ago

Can you may be provide a full gist to reproduce your case? And I need a bit more of information.

What does really happen. Just keep always in mind if you open an issue, no matter where: Be as verbose as possible, otherwise the ones working on your issue will have a hard time to figure out what your problem actually is.

If you could provide a full gist that proofable reproduces your case, that would be awesome already, currently I can't see anything in the information you provided yet, as there are neither any logs posted nor full examples of the relevant code. You have posted an example where I can just see you requiring this module, but not actually seeing you using it.

As soon as you provide enough information, I will give this another look and will try to help you.