• Resolved Jora Vartanov

    (@ruslancic)


    Hey! I have working redis on some of my servers, which runDebian+Nginx + php7.4!

    Now, i ahve another fresh server, that runs CentOS+Nginx+php8.1!

    And when i try to install Redis Object Cache, via >

    wp plugin install redis-cache --activate and wp redis enable, my site goes down, and i have this error in nginx logs:

    2023/11/16 13:50:38 [error] 42567#42567: *1139 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Call to undefined function Predis\Connection\stream_socket_client() in /var/www/example/www/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/StreamConnection.php:108
    Stack trace:
    #0 /var/www/example/www/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/StreamConnection.php(184): Predis\Connection\StreamConnection->createStreamSocket()
    #1 /var/www/example/www/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/StreamConnection.php(83): Predis\Connection\StreamConnection->unixStreamInitializer()
    #2 /var/www/example/www/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/AbstractConnection.php(80): Predis\Connection\StreamConnection->createResource()
    #3 /var/www/example/www/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/StreamConnection.php(230): Predis\Connection\AbstractConnection->connect()

    Can you help me with this? Thx in advance!

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Support Julie

    (@julieadrienne)

    Can you try using PhpRedis instead?

    define('WP_REDIS_CLIENT', 'phpredis');
    Thread Starter Jora Vartanov

    (@ruslancic)

    Have been tryed! This is my configuration:

    define( 'WP_REDIS_CLIENT', 'phpredis' );
    define( 'WP_REDIS_SCHEME', 'unix' );
    define( 'WP_REDIS_PATH', '/var/run/redis/redis.sock' );
    define( 'WP_REDIS_DATABASE', 0 );
    Stack trace:
    #0 /var/www/www.example/www/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/StreamConnection.php(154): Predis\Connection\StreamConnection->createStreamSocket()
    #1 /var/www/www.example/www/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/StreamConnection.php(80): Predis\Connection\StreamConnection->tcpStreamInitializer()
    #2 /var/www/www.example/www/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/AbstractConnection.php(80): Predis\Connection\StreamConnection->createResource()
    #3 /var/www/www.example/www/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/StreamConnection.php(230): Predis\Connection\AbstractConnection->connect()
    #4 /var/www/www.example/www/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Client.php(225): Predis\Connection\StreamConnection->connect()
    #5 /var/www/www.example/www/wp-content/plugins/redis-cache/includes/class-predis.php(127): Predis\Client->connect()
    #6 /var/www/www.example/www/wp-content/plugins/redis-cache/includes/class-plugin.php(596): Rhubarb\RedisCache\Predis->connect()
    #7 /var/www/www.example/www/wp-content/plugins/redis-cache/includes/ui/tabs/overview.php(16): Rhubarb\RedisCache\Plugin->check_redis_connection()
    #8 /var/www/www.example/www/wp-content/plugins/redis-cache/includes/ui/class-tab.php(167): include('...')
    #9 /var/www/www.example/www/wp-content/plugins/redis-cache/includes/ui/settings.php(60): Rhubarb\RedisCache\UI\Tab->display()
    #10 /var/www/www.example/www/wp-content/plugins/redis-cache/includes/class-plugin.php(204): require_once('...')
    #11 /var/www/www.example/www/wp-includes/class-wp-hook.php(324): Rhubarb\RedisCache\Plugin->show_admin_page()
    #12 /var/www/www.example/www/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
    #13 /var/www/www.example/www/wp-includes/plugin.php(517): WP_Hook->do_action()
    #14 /var/www/www.example/www/wp-admin/admin.php(259): do_action()
    #15 /var/www/www.example/www/wp-admin/options-general.php(10): require_once('...')
    #16 {main}
      thrown
    Plugin Support Julie

    (@julieadrienne)

    Thanks for testing that. I looks like your PHP installation is missing the the Sockets extension: https://www.php.net/manual/en/intro.sockets.php

    Are you managing the server yourself, or do you use a managed hosting provider?

    Thread Starter Jora Vartanov

    (@ruslancic)

    Is my server, self managment!

    Plugin Support Julie

    (@julieadrienne)

    In that case, depending how you install PHP, you may need to recompile it with the --enable-sockets flag: https://stackoverflow.com/questions/6137823/fatal-error-call-to-undefined-function-socket-create

    Sockets are needed to allow the PHP process to communicate with Redis Server.

    Thread Starter Jora Vartanov

    (@ruslancic)

    Hi again! My PHP installation have sockets enabled!

    1. Using another plugin, connection to redis was succesifuly, and all working good(i want this plugin).
    2. using php -m | grep sockets, i got: sockets,
    3. I think, the problem is not the sockets!
    4. Thx in advance!
    Thread Starter Jora Vartanov

    (@ruslancic)

    HI! I found the answer to the first problem! These were the permissions I had to give to redis, using the command usermod -a -G redis username.
    Now the plugin works, I see the statistics, from the redic-cli monitor I see the traffic, I see everything, the only problem is that I can’t access the plugin’s main page! Here are two screenshots:

    Working dshboard!

    2023/11/17 20:46:21 [error] 7981#7981: *106 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Call to undefined function Predis\Connection\stream_socket_client() in /var/www/example.com/www/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/StreamConnection.php:108
    Stack trace:
    #0 /var/www/example.com/www/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/StreamConnection.php(184): Predis\Connection\StreamConnection->createStreamSocket()
    #1 /var/www/example.com/www/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/StreamConnection.php(83): Predis\Connection\StreamConnection->unixStreamInitializer()
    #2 /var/www/example.com/www/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/AbstractConnection.php(80): Predis\Connection\StreamConnection->createResource()
    #3 /var/www/example.com/www/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/StreamConnection.php(230): Predis\Connection\AbstractConnection->con" while reading upstream, client: 185.285.171.62, server: example.com.it, request: "GET /wp-admin/options-general.php?page=redis-cache HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/example.com.it.sock:", host: "www.example.com.it", referrer: "https://www.example.com.it/wp-admin/index.php"

    Server configuration:

    Linux CentOS 8;

    Nginx 1.23;

    Percona MySQL;

    PHP-FPM 8.1;

    Redis server v=6.0.20 malloc=jemalloc-5.1.0 bits=64 build=8d6796f46240ad60

    Plugin Support Julie

    (@julieadrienne)

    That’s odd. Maybe it’s a bug in the Predis library.

    Can you create a test file called socket-test.php with this content:

    <?php
    var_dump(function_exists('stream_socket_client'));

    And then request it via CLI or HTTP and post the output here?

    Thread Starter Jora Vartanov

    (@ruslancic)

    Can you create a test file called?socket-test.php?with this content:

    An interesting thing!
    Using HTTP Request, from browser(https://www.ex.com/socket-test.php), I get: bool(false),
    Using wp eval-file socket-test.php, I get: bool(true);

    Plugin Support Julie

    (@julieadrienne)

    That means that your PHP version running in FPM doesn’t have the sockets extension compiled.

    Thread Starter Jora Vartanov

    (@ruslancic)

    That means that your PHP version running in FPM doesn’t have the sockets extension compiled.

    But, im conected to redis with your plugin, and i recieved data, and is working good! The only problem is you dashboard… And how to check if my php have been coompiled with sockets?

    Plugin Support Julie

    (@julieadrienne)

    Aaaahh, I understand. Can you post your diagnostics from Settings > Redis?

    Thread Starter Jora Vartanov

    (@ruslancic)

    Julie

    (@julieadrienne)

    Aaaahh, I understand. Can you post your diagnostics from?Settings > Redis?
    Plugin Support Julie

    (@julieadrienne)

    We’ll fix this in an update this week ??

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Connection error Predis\Connection’ is closed to new replies.