Hi,

I'm working in realtime posts using socket.io,

Stream is updating realtime but the problem is redis subscription happens 
multiple times and the post appears multiple times in the stream.

I'm using node.js cluster module to create multiple node clusters. Here is 
the code,

*worker.js*

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


*publisher.js*

// headvar redis      = require("socket.io/node_modules/redis");var pub        
= redis.createClient();// inside a funtion 
pst = member + "::" + data.pid
pub.publish("userstreams", pst);

The client publishes the postID only once but I'm getting multiple 
subscriptions in the userstreams channel in server.

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. 

Any idea where i'm going wrong?

P.S. 

I have also added this as a Stackoverflow 
<http://stackoverflow.com/questions/23220034/redis-subscribes-multiple-times-when-using-node-cluster-socket-io>
 question 


Thanks,

Srikanth

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to