Skip to content

Error: node_redis command queue state error. If you can reproduce this, please report it. #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
twmobius opened this issue Oct 2, 2011 · 3 comments
Labels

Comments

@twmobius
Copy link

twmobius commented Oct 2, 2011

Hello,

Using this snippet:

var redis = require('redis');

var subscriber = redis.createClient();
var publisher  = redis.createClient();

subscriber.on('message', function(channel, data) {
  console.log(data);

  subscriber.unsubscribe('test');
});

subscriber.subscribe('test');

setTimeout( function() {
  publisher.publish('test', 'Testing', function() {
    console.log("Published");
  });

  subscriber.unsubscribe('test');
}, 1000);

Crashes node-redis. In theory if the channel is already unsubscribed redis should not try to unsubscribe it again (If I understand why the error happens)

Great job btw :) Thank you!

@jsolla
Copy link

jsolla commented Jan 21, 2012

I can confirm this bug.

My situation is:

I'm working on an application to notify realtime variables (temperature/humidity,etc) to web-browser clients, using node/socket.io/redis.

At my node code I've the following lines:

cliSocket.on('subscribe',function(msg)
{
    console.log("Subscription request:"+msg.channel);

    // Only one subscription allowed per client
    redisCli.punsubscribe("*");

    // Subscribe to new channel
    redisCli.subscribe(msg.channel);
});

Test steps:

  1. Start node server with the depicted code....
  2. Open a browser and connect to the node server
  3. Browser sends a "subscribe" command using socket.io
  4. Redis_cli crashes.

The problem is this line: redisCli.punsubscribe("*"); if I comment out this line, it no longer crashes.

If more tests are needed, just let me know.

@DTrejo
Copy link
Contributor

DTrejo commented Apr 28, 2012

To prevent this from crashing redis, add the following. The command state queue error is caused by the double unsubscribe (or trying to unsubscribe when you are not subscribed to anything, in @jsolla's case?). Not really sure if there's a good way to fix this in node_redis, if either of you would like to submit pull requests, I would be happy to look them over and most-likely merge.

@jsolla: you may not need to supply the *? http://redis.io/commands/punsubscribe

Cheers and thanks!

D

subscriber.on('error', function(e) {
   console.log('subscriber', e.stack); 
});

publisher.on('error', function(e) {
   console.log('publisher', e.stack); 
});

@DTrejo DTrejo closed this as completed Apr 28, 2012
BridgeAR added a commit that referenced this issue Mar 26, 2016
Fix pub sub mode

Fixes #603 
Fixes #577 
Fixes #137
@BridgeAR
Copy link
Contributor

This is finally fixed on master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants