I've installed PhpRedis and verified Redis is working with redis-server PING

When I use the lock backend I get:
$ drush cc all
PHP Fatal error: Call to a member function incr() on a non-object in /sites/all/modules/contrib/redis/lib/Redis/Lock/Backend/PhpRedis.php on line 54

When I disable the lock backend I get:
$ drush cc all
' as reply type byte [error]
in Redis->exec() (line 96 of sites/all/modules/contrib/redis/lib/Redis/Cache/PhpRedis.php).
WD php: Warning: Cannot modify header information - headers already sent by (output started at [warning]
/usr/share/drush/includes/drush.inc:820) in drupal_send_headers() (line 1239 of
bootstrap.inc).
' as reply type byteerror, got '
in Redis->exec() (line 96 of sites/all/modules/contrib/redis/lib/Redis/Cache/PhpRedis.php).

Comments

pounard’s picture

Status: Active » Postponed (maintainer needs more info)

Thanks for reporting.

Working with Drush only? You don't have any problems while browsing the site?

aidanlis’s picture

Status: Postponed (maintainer needs more info) » Active

Website produces the same,

RedisException: protocol error, got ' ' as reply type byte in Redis->exec() (line 96 of sites/all/modules/contrib/redis/lib/Redis/Cache/PhpRedis.php).

Running redis-server on Debian, 2:1.2.6-1

Cheers,

pounard’s picture

Thanks you very much.

I will try to reproduce it but I'll need a few more details:

  • Can you paste or join your settings.php file (please offuscate your passwords from it)?
  • Can you give me the following versions of:
    • Redis
    • PHP
    • PhpRedis
aidanlis’s picture

PHP: 5.3.3-7+squeeze14
PhpRedis: Redis Version => 2.2.1
Redis: 2:1.2.6-1

The relevant bits of settings.php (everything else is stock standard):

$conf['cache_backends'] = array();

$conf['redis_client_interface']      = 'PhpRedis';
$conf['cache_backends'][]            = 'sites/all/modules/contrib/redis/redis.autoload.inc';
$conf['cache_class_cache']           = 'Redis_Cache';
$conf['cache_class_cache_menu']      = 'Redis_Cache';
$conf['cache_class_cache_bootstrap'] = 'Redis_Cache';
$conf['lock_inc'] = 'sites/all/modules/contrib/redis/redis.lock.inc';
pounard’s picture

Thank you very much, I will try this as soon as I have time.

pounard’s picture

I'm not forgetting you, I still don't have an environment where I can work this out @work. This would be a good idea to test again thought because I fixed some bugs recently.

pounard’s picture

Status: Active » Closed (cannot reproduce)

Hello again, I did a quick and dirty test on by box, a freshly installed Drupal 7 (latest stable).
I'm using this software version:
- Drush 7.x-5.7
- Redis server 2.2.14
- An rather old version of PhpRedis (I'm trying to update it right now)
- Drupal core 7.15

And it works quite well.

So, I have a new question: are you sure the PhpRedis extension is correctly enabled on your PHP CLI environment?

EDIT: Just updated to latest git version of PhpRedis, still no issues.

Some thoughts: maybe update your Redis? Update PhpRedis first, you might have used a buggy version! I'm closing this issue as cannot reproduce, but if you any new details, please re-open!

Fidelix’s picture

I am experiencing this exact problem as well.
PHPRedis compiled from the github source.

It does not happen on my local machine, but on my staging server, it does.
The only difference that I can tell is that the Redis server is not running on localhost on the staging server.
It is located in another virtual machine, which I can telnet to the redis port and run $redis->ping if I create a php script from scratch.

Fidelix’s picture

$conf['redis_client_host'] = 'webservices';
$conf['redis_client_port'] = 6379;
$conf['redis_client_interface'] = 'PhpRedis';
$conf['cache_backends'][] = 'sites/all/modules/contrib/redis/redis.autoload.inc';
#$conf['cache_default_class'] = 'Redis_Cache';
#$conf['lock_inc'] = 'sites/all/modules/contrib/redis/redis.lock.inc';
$conf['redis_client_base'] = 7;

This isn't generating any errors.

As soon as I uncomment this line:

#$conf['cache_default_class'] = 'Redis_Cache';

Hell breaks loose.

RedisException: protocol error, got ' ' as reply type byte in Redis->exec() (line 96 of /XXX/sites/all/modules/contrib/redis/lib/Redis/Cache/PhpRedis.php).
pounard’s picture

Status: Closed (cannot reproduce) » Active

@Fidelix, please tell me exact versions you are using of:
- PhpRedis
- PHP
- Drupal core
- Redis module
And any other information you might think useful. I'd very much like to reproduce this bug but I could not the first time.

Fidelix’s picture

Redis 1.2.6 from dotdeb
PHPRedis 2.2.2 http://i.imgur.com/BVvsHXH.png
PHP Version 5.3.21-1~dotdeb.0
Drupal 7.19
Redis module: 7.x-2.0-beta4 (But at first, I was trying on an old dev version)

Apparently, it is breaking on:
https://github.com/nicolasff/phpredis/blob/master/library.c

Function redis_sock_read() or redis_read_variant_reply()

Fidelix’s picture

Status: Active » Closed (works as designed)

(facepalm)

Redis 1.2.6 from dotdeb

There is my answer.

Actually, the server where I had Redis installed did not have dotdeb configured, so it was using the default debian Redis package.
After compiling Redis manually, it worked like a charm. Then I removed it, configured dotdeb, installed it again, and it works wonders.

Really sorry for taking your time.

pounard’s picture

Title: Errors with PhpRedis » Document that recent PhpRedis needs a recent Redis server
Version: 7.x-2.0-alpha9 » 7.x-2.0-beta4
Component: Code » Documentation
Category: bug » task
Status: Closed (works as designed) » Needs work

Don't worry, I didn't loose time on this one, so you're saying it's because of a version mismatch between Redis and PhpRedis? It worth the shot to document it in the module.

Fidelix’s picture

Assigned: Unassigned » Fidelix

That's correct. It appears most of the new commands on PHPRedis need at least Redis 2.x to work.

I will submit a patch with a documentation update.

pounard’s picture

Status: Needs work » Fixed

After some thoughts, I think we can't seriously support Redis versions prior to 2.4 (missing WATCH command for a start). So I will document that this module is untested and potentially unstable or not working at all with older Redis versions.

I'm marking this as fixed as I commit the documentation fix. Please re-open if you disagree or have new arguments to bring.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

c4rl’s picture

Title: Document that recent PhpRedis needs a recent Redis server » Document correct Redis server version
Version: 7.x-2.0-beta4 » 7.x-2.6
Assigned: Fidelix » Unassigned
Issue summary: View changes
Status: Closed (fixed) » Needs work

I have a few suggestions.

  1. README.txt is now inconsistent, it references requiring at least Redis 2.1, then at least Redis 2.4.
  2. It might be useful to have hook_requirements check for the Redis version.

  • Commit fa7ec78 on 7.x-2.x by Pierre.R:
    Fixes #1729808 - thanks to aidanlis, Fidelix, c4rl - Redis v2.4.0 is now...
pounard’s picture

Status: Needs work » Fixed

I didn't implement the hook_requirements() because the module does not require to be activated. Otherwise I documented that Redis >=2.4.0 only is supported. Thank you very much.

c4rl’s picture

Thanks :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.