title: Redis Subscribes multiple times when using Node Cluster, Socket.io
body: <p>I'm working in realtime posts using socket.io, </p>
  
  <p>Stream is updating realtime but the problem is redis subscription happens multiple times and the post appears multiple times in the stream. </p>
  
  <p>I'm using node.js <code>cluster module</code> to create multiple node clusters. Here is the code,</p>
  
  <p><strong>worker.js</strong></p>
  
  <pre><code>var cluster    = require('cluster');
  var server     = new Hapi.Server(config.port,view_options);
  
  var socketIO   = require('socket.io');
  var redis      = require("socket.io/node_modules/redis");
  var RedisStore = require('socket.io/lib/stores/redis');
  
  var io         = socketIO.listen(server.listener);
  var sub        = redis.createClient();
  sub.setMaxListeners(0);
  
  io.configure(function() {
      io.set('store', new RedisStore({
          redisSub : sub
      }));
      io.set('transports', ['xhr-polling']);
      io.set('polling duration', '10');
  });
  
  if (cluster.isMaster) {
       for (var i = 0; i &lt; numCPUs; i++) {
          cluster.fork();
      }
  } 
  else {
      sub.subscribe("userstreams");
      io.sockets.on('connection', function(socket) {
      // Realtime streams : subscribe to redis channel userstreams
          sub.on("message", function(channel, member_postid) {
              console.info("-----------realtime post receieved --------",member_postid);                
          });        
      });
  }
  </code></pre>
  
  <p><strong>publisher.js</strong></p>
  
  <pre><code>// head
  var redis      = require("socket.io/node_modules/redis");
  var pub        = redis.createClient();
  // inside a function 
  pst = member + "::" + data.pid
  pub.publish("userstreams", pst);
  </code></pre>
  
  <p>The client publishes the postID only once but I'm getting multiple subscriptions in the userstreams channel in server. </p>
  
  <p>I want my server to get the redis subscription only once so that I can send them in socket to a user's stream only once. </p>