Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fixing the "protocol error, got '*' as reply type byte" #13

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

Merged
merged 1 commit into from
Jul 17, 2011

Conversation

MichelBartz
Copy link

This error was occurring when a SORT was being executed on an empty list or set.

@nicolasff
Copy link
Member

'*' is a multi-bulk reply, they're handled in the various redis_sock_read_multibulk_reply_* functions.

Do you have a test case for this error? I've tried running SORT on a non-existing sorted set, and have received no error:

<?php

$redis = new Redis();
$redis->connect('127.0.0.1', 6379);

$redis->del('x');
var_dump($redis->sort('x'));

?>

array(0) {
}

@MichelBartz
Copy link
Author

That's what surprised me as well here is a sample code :

        $this->zInter($tempKey, $sortedSets);

        $res = $this->sort($tempKey, array("by" => $sortBy,
                                       "limit" => array((int)$offset, (int)$limit),
                                       "sort" => $order,
                                       "store" => $sortTemp));

The case was zInterStore failing because one of the sorted set was non existing resulting in the sort command failing as well. (and throwing the error mentioned)

I think it's related to the fact we use "store" , the extension uses "redis_long_response" which itself use redis_sock_read where they was no way of handling * as response type. (which seems weird as when we use store it should be a long response and not a multi_bulk)

@dexmans
Copy link

dexmans commented Jul 13, 2011

I get the same error when using brpoplpush with a timeout of 10 seconds on any type of connection... (normal or persistent)

PHP Fatal error: Uncaught exception 'RedisException' with message 'protocol error, got '*' as reply type byte'

    $data = $redis->brpoplpush($queue, $workingQueue, 10);

When using

    $redis->brpop($queue, 10);

There is no problem.

I'm using the latest versions of https://github.com/nicolasff/phpredis/ with redis 2.2.11

(the command on redis-cli works fine btw)

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

Successfully merging this pull request may close these issues.

3 participants