We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Cannot connect to Redis through a socket

Hi, I've run into a problem when trying to connect to Redis through a socket and I am not sure how to tackle it.

When having:

$cache = new Redis( $frontCache, [ "host" => "/var/redis.sock", "auth" => "connection_strict_password", "persistent" => false, ] );

there should be no port defined (no "port" param or "port" => null).

Nevertheless, I see that in https://github.com/phalcon/cphalcon/blob/master/phalcon/cache/backend/redis.zep:83 one forces a default value for the port, if not defined:

  if !isset options["port"] {
      let options["port"] = 6379;

Hence I am not able to connect to Redis through the socket.

Any hint/idea how to cope with it? Thx!

Try with port => 0

This is my definition for libMemcached:

$daemon = new Session(
        ['servers'  => [['host' => $config->_daemon->socket, 'port' => $config->_daemon->pipe, 'weight' => $config->_daemon->weight]],

        // pipe in config = 0

Thx, but unfortunately it's no better. Until the source code will get changed in a new version (from my point of view the if in line 83 shouldn't be there), eventually I had to opt for a different implementation. Thx again.

if !isset options["port"] that chack should not play role if you set something for a port number, such as 0. libMemcached works like a charm with that configuration.