background
Because of the high concurrency, the project changed the connection redis from a short connection to a long connection. As a result, a Read error on connection was raised
A reason for
PHP has a configuration item default_socket_timeout that specifies the timeout period for a socket connection. The default value is 60 seconds. The underlying connection redis is the socket used by phpredis. The next time the connection throws this exception.
The solution
Option 1 Modify php.ini(not recommended)
In php.ini, set default_socket_timeout = -1 and restart php-fpm
Scheme 2 program Settings
Use the ini_set function ini_set(‘default_socket_timeout’, -1); / / no timeout
Scheme 3 uses the redis option
$this->redis->setOption(redis ::OPT_READ_TIMEOUT, -1);
Note that any timeout setting should be set to -1 instead of 0
Reference article:
Github.com/phpredis/ph…