title: Socket.io with Node Cluster Module
body: <p><br>
  I am looking to run a Node.js application with the Node cluster module and socket.io. I got it setup using sticky-session and it works but my issue is as following : <br>
  If I connect for example to worker 5.<br>
  Another person connects for example to worker 4.<br>
  And when I send a message only the other persons on the same worker receive the message, but I want that if I send a message on 1 worker that it gets send to each other worker aswell.</p>
  
  <p>Here my server code.</p>
  
  <pre><code>var sticky = require('sticky-session'),
      http = require('http'),
      express = require('express'),
      socketIO = require('socket.io'),
      cluster = require('cluster'),
      port = process.env.PORT || 3003;
  
    var app = express(), io;
  
    server = http.Server(app);
  
    app.get('/', function(req, res) {
      res.sendfile('index.html');
    });
  
    io = socketIO(server);
    let totalUsers = 0;
  
    io.on('connection', function(socket) {
      socket.on('chat message', function(msg) {
        console.log("got request");
        io.emit('chat message', msg+" send by worker "+cluster.worker.id);
      });
    });
  
  if(!sticky.listen(server,port))
  {
    server.once('listening', function() {
      console.log('Server started on port '+port);
    });
  
    if (cluster.isMaster) {
      console.log('Master server started on port '+port);
    }
  }
  else {
      console.log('- Child server started on port '+port+' case worker id='+cluster.worker.id);
  }
  </code></pre>
  
  <p>Here my client code</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;Socket.IO chat&lt;/title&gt;
      &lt;style&gt;
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body { font: 13px Helvetica, Arial; }
        form { background: #000; padding: 3px; position: fixed; bottom: 0; width: 100%; }
        form input { border: 0; padding: 10px; width: 90%; margin-right: .5%; }
        form button { width: 9%; background: rgb(130, 224, 255); border: none; padding: 10px; }
        #messages { list-style-type: none; margin: 0; padding: 0; }
        #messages li { padding: 5px 10px; }
        #messages li:nth-child(odd) { background: #eee; }
        #messages { margin-bottom: 40px }
      &lt;/style&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;ul id="messages"&gt;&lt;/ul&gt;
      &lt;form action=""&gt;
        &lt;input id="m" autocomplete="off" /&gt;&lt;button&gt;Send&lt;/button&gt;
      &lt;/form&gt;
      &lt;script src="https://cdn.socket.io/socket.io-1.2.0.js"&gt;&lt;/script&gt;
      &lt;script src="https://code.jquery.com/jquery-1.11.1.js"&gt;&lt;/script&gt;
      &lt;script&gt;
        $(function () {
          var socket = io();
          $('form').submit(function(){
            socket.emit('chat message', $('#m').val());
            $('#m').val('');
            return false;
          });
          socket.on('chat message', function(msg){
            $('#messages').append($('&lt;li&gt;').text(msg));
            window.scrollTo(0, document.body.scrollHeight);
          });
        });
      &lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>