8

I use Redis to build a IOS SNS App (for restful api). As more user use it, errors happened.

It throws out :

Uncaught exception 'RedisException' with message 'read error on connection' 
in /data1/www/htdocs/11/iossns/Model/Core/Redis.php

I don't know how to solve the problem.

Can you help?

Thank you!

Guido Gautier
  • 1,237
  • 9
  • 13
taogogo
  • 81
  • 1
  • 3

3 Answers3

1

What PHP-to-Redis library are you using? Here’s the official list from Redis. What is your webserver? (Apache, nginx, etc) How is PHP running? (CGI, FPM, mod_php, etc)

Here’s a thread for the same exception message in phpredis. It turns out phpredis does not currently support persistent connections with php-fpm. Version 2.2.3 of phpredis has some connection handling changes that might decrease the frequency of your issues.

I recommend checking your Redis connector configuration to…

  1. disable persistent connections
  2. enable connection retries
  3. increase log verbosity

You might also consider adjustments to (generally increasing) default_socket_timeout in php.ini.

parhamr
  • 557
  • 5
  • 12
0

It's a redis 6 bug.

You can do this:

sudo nano /etc/systemd/system/redis.service

# ADD THIS TO [Service] SECTION

ExecStartPost=/bin/sh -c "echo $MAINPID > /var/run/redis/redis.pid"

sudo systemctl daemon-reload && sudo systemctl restart redis-server
Elikill58
  • 4,050
  • 24
  • 23
  • 45
-1

In my case in Ubuntu 20.04 I discovered systemctl was trying to restart service because it couldn't find the /run/redis/redis-server.pid redis-server.service: Failed with result 'timeout'.

Feb 25 17:51:09 artamredis systemd[1]: Failed to start Advanced key-value store.
Feb 25 17:51:09 artamredis systemd[1]: redis-server.service: Scheduled restart job, restart counter is at 18.
Feb 25 17:51:09 artamredis systemd[1]: Stopped Advanced key-value store.
Feb 25 17:51:09 artamredis systemd[1]: Starting Advanced key-value store...
Feb 25 17:51:09 artamredis systemd[1]: redis-server.service: Can't open PID file /run/redis/redis-server.pid (yet?) after start: Operation not permitted

In order to solve it in /etc/redis/redis.conf file find

pidfile /var/run/redis_6379.pid

and change to

pidfile /run/redis/redis-server.pid
Sami Onur Zaim
  • 502
  • 6
  • 6