Failed to get Session with redis

I getting the following error, when I try to use the redis cache:

[18-Jan-2024 18:10:10 Europe/Berlin] PHP Fatal error:  Uncaught Zend_Session_Exception:
Zend_Session::start() - /home/fallguys/public_html/engine/Library/Zend/Session.php(Line:468): Error 
#2 session_start(): Failed to read session data: files (path: tcp://127.0.0.1:6379) in /home/fallguys
/public_html/engine/Library/Zend/Session.php:481

It is working in another shopware 5 instance, but on this here, it is not working, and I don’t know what I make wrong.

config.php

  'session' => array(
    'save_handler' => 'redis',
    'save_path' => "tcp://127.0.0.1:6379",
  ),

Ping the Cache

[fallguys@web01 public_html]$ redis-cli ping
PONG

Redis 6.2.7
AlmaLinux/CloudLinux 8.9
PHP 7.4.33
Shopware 5.6.9

Hi,

maybe your Redis Server is listening to the socket only (you can check in your /etc/redis/redis.conf file).

If so, try:

'session' => [
    'save_handler' => 'redis',
    'save_path' => "/var/run/redis/redis-server.sock",
  ],

PS. Socket connections are faster than a TCP connection.

Regards

Hi, no tcp is working fine. Teset it with netstat -lnp and with telnet 127.0.0.1 6379
Cannot use sockets, because of a chroot/cagefs security environment on cPanel server.

Hm, maybe this helps in a cPanel / CageFS environment:

Is there any known bug with PHP 7.4.33 and PECL Redis Module?
the log says Failed to read session data: files why „files“ ?? it should be redis. Because of this, it seems to be files are used, it cannot read from filesystem path tcp://…, would be logical.
It should switch to redis.

The message is correct - your PHP session files will be stored in Memory (Redis) instead of the file-system.

Using redis-cli monitor you can check the activity, here´s some sample output of a Shopware 5 Shop (running Almalinux 8, Cloudlinux, CageFS with Plesk):

1705602752.644828 [0 127.0.0.1:52020] „SETEX“ „PHPREDIS_SESSION:nqp7elvu4lfe0kuutf1lu1nor6“ „7200“ „ShopwareBackend|a:2:{s:12:"X-CSRF-Token";s:30:"MIkyl0R5siTmUxRp6jgbJJLbxtXCkk";s:4:"Auth";O:8:"stdClass":18:{s:2:"id";s:2:"50";s:6:"roleID";s:1:"1";s:8:"username";s:9:"xxxxxx";s:8:"password";s:60:"xxxxxxxxxxxxxxxxx";s:7:"encoder";s:6:"bcrypt";s:6:"apiKey";s:40:"udmRMPaN4uBzStL9zz3gEdig9zDHOUvMggqTwom4";s:8:"localeID";s:1:"1";s:9:"sessionID";s:26:"5tvh9m97insa3bgb7one269ado";s:9:"lastlogin";s:19:"2024-01-18 14:45:26";s:4:"name";s:13:"Administrator";s:5:"email";s:30:"xxxxxxxxxxxxxxxxx";s:6:"active";s:1:"1";s:12:"failedlogins";s:1:"0";s:11:"lockeduntil";s:19:"2020-06-07 20:13:42";s:15:"extended_editor";s:1:"1";s:14:"disabled_cache";s:1:"0";s:4:"role";O:25:"Shopware\Models\User\Role":11:{s:29:"\x00Shopware\Models\User\Role\x00id";i:1;s:35:"\x00Shopware\Models\User\Role\x00parentId";N;s:31:"\x00Shopware\Models\User\Role\x00name";s:12:"local_admins";s:38:"\x00Shopware\Models\User\Role\x00description";s:53:"Default group that gains access to all shop functions";s:33:"\x00Shopware\Models\User\Role\x00source";s:8:"build-in";s:34:"\x00Shopware\Models\User\Role\x00enabled";i:1;s:32:"\x00Shopware\Models\User\Role\x00admin";i:1;s:32:"\x00Shopware\Models\User\Role\x00users";O:33:"Doctrine\ORM\PersistentCollection":2:{s:13:"\x00*\x00collection";O:43:"Doctrine\Common\Collections\ArrayCollection":1:{s:53:"\x00Doctrine\Common\Collections\ArrayCollection\x00elements";a:0:{}}s:14:"\x00*\x00initialized";b:0;}s:32:"\x00Shopware\Models\User\Role\x00rules";O:33:"Doctrine\ORM\PersistentCollection":2:{s:13:"\x00*\x00collection";O:43:"Doctrine\Common\Collections\ArrayCollection":1:{s:53:"\x00Doctrine\Common\Collections\ArrayCollection\x00elements";a:0:{}}s:14:"\x00*\x00initialized";b:0;}s:35:"\x00Shopware\Models\User\Role\x00children";O:33:"Doctrine\ORM\PersistentCollection":2:{s:13:"\x00*\x00collection";O:43:"Doctrine\Common\Collections\ArrayCollection":1:{s:53:"\x00Doctrine\Common\Collections\ArrayCollection\x00elements";a:0:{}}s:14:"\x00*\x00initialized";b:0;}s:33:"\x00Shopware\Models\User\Role\x00parent";N;}s:6:"locale";O:27:"Shopware\Models\Shop\Locale":4:{s:31:"\x00Shopware\Models\Shop\Locale\x00id";i:1;s:35:"\x00Shopware\Models\Shop\Locale\x00locale";s:5:"de_DE";s:37:"\x00Shopware\Models\Shop\Locale\x00language";s:7:"Deutsch";s:38:"\x00Shopware\Models\Shop\Locale\x00territory";s:11:"Deutschland";}}}_symfony_flashes|a:0:{}_sf2_meta|a:3:{s:1:"u";i:1705602752;s:1:"c";i:1705602720;s:1:"l";i:0;}“

Maybe post your redis.conf here.

The Shop mentioned above is using PHP 7.4.33 with the following Redis Setup in config.php:

'session' => [
    'save_handler' => 'redis',
    'save_path' => "127.0.0.1:6379",
  ],

  'backendsession' => [
    'save_handler' => 'redis',
    'save_path' => "127.0.0.1:6379",
  ],

Try to remove tcp:// like shown in my example.

Here´s the Redis Version I am using:

[root@srv01 httpdocs]# redis-cli INFO server
# Server
redis_version:5.0.3
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:14b81d825631ff0c
redis_mode:standalone
os:Linux 4.18.0-513.9.1.lve.el8.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:8.4.1
process_id:1058
run_id:451d60649ab0a98afc0930dcd369a2cb5ce49e0d
tcp_port:6379
uptime_in_seconds:1801822
uptime_in_days:20
hz:10
configured_hz:10
lru_clock:11104639
executable:/usr/bin/redis-server
config_file:/etc/redis.conf
[root@srv01 httpdocs]#

PS. Your issue could be related to Redis 6.x where authentication has been introduced:

Well, that’s another great mistake. Somehow a PHP version has crept into the CageFS account that has no redis.so module loaded.

Now I have one Shopware account that works and another that doesn’t, on the same CloudLinux/cPanel server.

In both cases, however, „Redis“ is active as a module in the configuration.
I’ll have to research this further and ask cPanel support if necessary.

By creating phpinfo() files I was able to track down the error.

Very strange!

Try

/usr/sbin/cagefsctl --disable username
/usr/sbin/cagefsctl --force-update 
/usr/sbin/cagefsctl --enable username

Had no effect… redis is not shown in phpinfo

Hm, the only other idea I had is that authentication may be enabled in your Redis 6 config and since you´re not providing a username/password in your config.php that this may cause the error (I am not sure if Shopware 5 even supports authentication).

But since you´re saying the other shop is working and the redis-php module missing in the CageFS setup of the other user it´s indeed pretty strange.

I have found a way!
I have switched to ea-php74 in MultiPHP Manager, after that I switched back to alt-php74 with Cloud Linux PHP Selector. Now redis modul is active!

… sounds like the configuration update fixed it in cPanel.

Thank you for the very quick and competent help here in the forum!

1 „Gefällt mir“