Using the same redis.createClient() instance for publish and subscribe
node.js, redis, socket.io
Solution
From the Redis docs:
Once the client enters the subscribed state it is not supposed to issue any other commands, except for additional SUBSCRIBE, PSUBSCRIBE, UNSUBSCRIBE and PUNSUBSCRIBE commands.
For this reason, you'll need two clients, one for subscribing and one for publishing (and potentially other commands).
Problem
I'm working with redis to publish and subscribe messages between socket.io clients, when client connects to the server (`io.sockets.on('connection', function(socket){...});`) i'm creating a `subscribe` variable using `redis.createClient()` and then using the subscribe function to subscribe the client to channel. My question is if its right to use the same subscribe variable to do a publish action? or it's important to create another instance with `redis.createClient()` for publishing messages so i will have 2 instances, one for publishing and one for subscribing... Thanks