2
votes

I got a game using Redis, Socket.io, theres 2 nodejs servers running diff socket.io clients. I am communicating with both socket.io clients through the redis store, that way I can emit to all sockets whenever I want. And it works.

io.sockets.emit('successful_connection', { success : true }); return;

My problem is, when ie calling a specific socket by id, it fails.

io.sockets.socket(socketId).emit('successful_connection', { success : true }); return;

I have no idea why, it works in all other browsers. Heres the code for socket.io/redis store config

    io.configure(function(){
        var RedisStore = require('socket.io').RedisStore,
            opts = {host: **.***.**.**, port: ****};
        io.set('store', new RedisStore({redisPub:opts, redisSub:opts, redisClient:opts}));
    });     

Any advice would be helpful, right now my main thought is "why have nodejs/socket.io servers." Is there really a benefit if i have to deal with this. Thanks

1
You mention "theres 2 nodejs servers running diff socket.io clients", so are they connecting to a socket.io server? If this is in error, can you please make sure you don't use the words "client" and "server" interchangeably? They don't mean the same thing and make it impossible to understand what is going on.geoffreak

1 Answers

0
votes

This blog post with example code might help you.