• Resolved Anonymous User 7326277

    (@anonymized-7326277)


    I have this weird issue after changing way plugin connects to the Redis. I’ve placed following two entries in wp-config.php file:

    define( 'WP_REDIS_SCHEME', 'unix' );
    define( 'WP_REDIS_PATH', '/var/run/redis/redis.sock' );

    When checking status via wp-cli utility I’m getting following result:

    $ wp redis status
    Status: Connected
    Client: PECL Extension (v3.0.0)

    But in website interface it says:

    Not Connected

    Any ideas or suggestions what to check?

Viewing 15 replies - 1 through 15 (of 20 total)
  • Plugin Author Till Krüss

    (@tillkruess)

    Weird, could you please post your “Diagnostics” section?

    Thread Starter Anonymous User 7326277

    (@anonymized-7326277)

    Sorry, here it is:

    PHP Version: 7.0.15
    Multisite: No
    Redis: 3.0.0
    Predis: 1.1.1
    Status: Not Connected
    Client: PECL Extension (v3.0.0)
    WP_REDIS_SCHEME: "unix"
    WP_REDIS_PATH: "\/var\/run\/redis\/redis.sock"
    WP_CACHE_KEY_SALT: ""
    Drop-in: Valid
    Global Prefix: "TABLEPREFIX_"
    Blog Prefix: "TABLEPREFIX_"
    Global Groups: ["blog-details","blog-id-cache","blog-lookup","global-posts","networks","rss","sites","site-details","site-lookup","site-options","site-transient","users","useremail","userlogins","usermeta","user_meta","userslugs"]
    Ignored Groups: ["counts","plugins","blog-details","blog-id-cache","blog-lookup","global-posts","networks","rss","sites","site-details","site-lookup","site-options","site-transient","users","useremail","userlogins","usermeta","user_meta","userslugs","themes"]

    I’ve replaced table prefix with “TABLEPREFIX” but that info should really not be relevant anyways.

    Plugin Author Till Krüss

    (@tillkruess)

    Can you try connecting using tcp and see if ui and cli show “Connected”?

    Thread Starter Anonymous User 7326277

    (@anonymized-7326277)

    tcp with unix socket combination? That is my report in fact, when using tcp and connecting via 127.0.0.1 it works flawlessly. If I bind redis to some other local IP and point redis plugin to it or use unix socket it results in situation mentioned in first post.

    Plugin Author Till Krüss

    (@tillkruess)

    I’d suggest just using tcp, or trying unix with Predis instead of PhpRedis.

    Thread Starter Anonymous User 7326277

    (@anonymized-7326277)

    Any idea then why, when using tcp with any other IP other than 127.0.0.1 I get completely same situatioN?

    To answer your other question about IPs I would assume it is a firewall issue, you can list your iptable rules with iptables -L

    Thread Starter Anonymous User 7326277

    (@anonymized-7326277)

    Redis is listening on a socket with permissions 770, ownership is redis:redis and user under which site is running is in redis group so it should be able to access it normally.

    Tried switching to predis but seems like it is not working:

    Client: PECL Extension (v3.0.0)
    WP_REDIS_CLIENT: “predis”

    Regarding IPTables, I’m not using Linux in this case so IPTables is not used,but to answer the question, firewall is not blocking access.

    That is very likely your problem @ivantomica I suggest you check out that link I posted before. Unless your php handler (php-fpm or apache) is running as the redis user or group then access will be denied.

    You can do a quick test with chmod 777 on the unix socket and re-test.

    Thread Starter Anonymous User 7326277

    (@anonymized-7326277)

    Tried that @blindpet , same issue.

    Please share the php handler you are using and the user name it runs under (netstat -lntp). Also please list ls -lh for the folder which contains your unix socket.

    Thread Starter Anonymous User 7326277

    (@anonymized-7326277)

    Permissions on the folder (bare in mind that I’ve tried changing permissions of the folder to 777 as well as socket perm to 777 just for testing purposes):

    root@www:~ # ls -ld /var/
    drwxr-xr-x  25 root  wheel  25 Feb 26 13:39 /var/
    root@www:~ # ls -ld /var/run
    drwxr-xr-x  5 root  wheel  18 Feb 27 03:45 /var/run
    root@www:~ # ls -ld /var/run/redis/
    drwxr-xr-x  2 redis  redis  4 Feb 26 21:21 /var/run/redis/
    root@www:~ # ls -ld /var/run/redis/redis.sock
    srwxrwx---  1 redis  redis  0 Feb 26 21:21 /var/run/redis/redis.sock

    Relevant part from php-fpm pool configuration:

    user = USER
    group = USER
    listen.owner = nobody
    listen.group = nobody

    Also note that I’m using redis as session handler without any issues for the same PHP pool:

    php_value[session.save_handler] = redis
    php_value[session.save_path]    = "unix:///var/run/redis/redis.sock"

    Sockstat output:

    root@www:~ # sockstat -l |grep redis
    redis    redis-serv 4473  4  tcp4   127.0.0.131:6379      *:*
    redis    redis-serv 4473  5  stream /var/run/redis/redis.sock

    PHP-FPM pool sockstat:

    root@www:~ # sockstat -l | grep php
    USER   php-fpm    5773  0  stream /var/run/www.DOMAIN
    USER   php-fpm    3412  0  stream /var/run/www.DOMAIN

    User:

    root@www:~ # id USER
    uid=1001(USER) gid=1001(USER) groups=1001(USER),535(redis)
    Thread Starter Anonymous User 7326277

    (@anonymized-7326277)

    Also tried changing group ownership of redis folder that contains socket to the primary group of user. No help.

    Can you share your redis.conf file too please @ivantomica

    Thread Starter Anonymous User 7326277

    (@anonymized-7326277)

    Here it is:

    root@www:~ # grep -v ^# /usr/local/etc/redis.conf | sed '/^$/d'
    bind 127.0.0.131
    protected-mode yes
    port 6379
    tcp-backlog 511
    unixsocket /var/run/redis/redis.sock
    unixsocketperm 770
    timeout 0
    tcp-keepalive 300
    daemonize yes
    supervised no
    pidfile /var/run/redis/redis.pid
    loglevel notice
    logfile /var/log/redis/redis.log
    databases 16
    save 900 1
    save 300 10
    save 60 10000
    stop-writes-on-bgsave-error yes
    rdbcompression yes
    rdbchecksum yes
    dbfilename dump.rdb
    dir /var/db/redis/
    slave-serve-stale-data yes
    slave-read-only yes
    repl-diskless-sync no
    repl-diskless-sync-delay 5
    repl-disable-tcp-nodelay no
    slave-priority 100
    appendonly no
    appendfilename "appendonly.aof"
    appendfsync everysec
    no-appendfsync-on-rewrite no
    auto-aof-rewrite-percentage 100
    auto-aof-rewrite-min-size 64mb
    aof-load-truncated yes
    lua-time-limit 5000
    slowlog-log-slower-than 10000
    slowlog-max-len 128
    latency-monitor-threshold 0
    notify-keyspace-events ""
    hash-max-ziplist-entries 512
    hash-max-ziplist-value 64
    list-max-ziplist-size -2
    list-compress-depth 0
    set-max-intset-entries 512
    zset-max-ziplist-entries 128
    zset-max-ziplist-value 64
    hll-sparse-max-bytes 3000
    activerehashing yes
    client-output-buffer-limit normal 0 0 0
    client-output-buffer-limit slave 256mb 64mb 60
    client-output-buffer-limit pubsub 32mb 8mb 60
    hz 10
    aof-rewrite-incremental-fsync yes
Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘Status: Not connected’ is closed to new replies.