Skip to content
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

what is the correct syntax of BLPOP on Predis? #42

Closed
geocine opened this issue Sep 28, 2011 · 2 comments
Closed

what is the correct syntax of BLPOP on Predis? #42

geocine opened this issue Sep 28, 2011 · 2 comments

Comments

@geocine
Copy link

geocine commented Sep 28, 2011

I do it like this:

$r = new Predis\Client($single_server, $options);
$retval = $r->blpop('queue:query');

But I get this error:

ERR wrong number of arguments for 'blpop' command

Whenever I do this

$r = new Predis\Client($single_server, $options);
$retval = $r->blpop('queue:query',0);

I get the error:

Error while reading line from the server

Doing it from redis-cli

redis 127.0.0.1:6379> BLPOP queue:query
(error) ERR wrong number of arguments for 'blpop' command
redis 127.0.0.1:6379> BLPOP queue:query 0
1) "queue:query"
2) "hello world"
@nrk
Copy link
Contributor

nrk commented Sep 28, 2011

The second one, that is $r->blpop('queue:query',0);, is correct, but 0 as a value for the timeout argument blocks indefinitely until a message is available in the queue. If you really want to wait forever for a message using BLPOP then you have to configure Redis to not close idle clients after 300 seconds (you can do this by editing your redis.conf and setting the timeout entry to 0) and add read_write_timeout => 0 to the server parameters array / string passed to the constructor of Predis\Client.

This is the common cause for such an error using BLPOP, but if it's something different than you should tell me:

  • your version of Redis
  • you version of PHP
  • on which OS platform you are running

@geocine
Copy link
Author

geocine commented Sep 28, 2011

I was pushing to a different database which is the default 0 . I used predis example which uses database 15. After I pushed data to 15. This error vanished Error while reading line from the server.

Thank you for the very detailed explanation.

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

No branches or pull requests

2 participants