I've been using Redis on a docker image for a short while (a week or so), installed through plesk with success. We've decided to upgrade the hardware of the VPS server and after the reboot the docker Redis throws "read error on connection" when trying to do anything other than connecting.
I've tried setting PHP's default_socket_timeout
ini_set('default_socket_timeout', -1);
and the redis timeout:
$clientRedis->setOption(Redis::OPT_READ_TIMEOUT, -1);
But still the error remains.. Here's my code I use for testing:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('default_socket_timeout', -1);
$clientRedis = new Redis();
function Redis_connect($hostname, $port){
$start = time();
global $clientRedis;
try {
$connected = $clientRedis->connect($hostname, $port);
$clientRedis->setOption(Redis::OPT_READ_TIMEOUT, -1);
if (!$connected) { throw new Exception(); }
} catch (Exception $e) {
$elapsed = time() - $start;
echo "Elapsed: " . $elapsed . "\n";
die($e->getMessage());
}
}
//Connecting to Redis server on localhost
echo Redis_connect("127.0.0.1", 6379);
echo "Connected to server successfully";
echo "";
echo "Server is running: " . $clientRedis->ping();
echo "";
?>
This outputs:
Connected to server successfully
Fatal error: Uncaught RedisException: read error on connection in [..]/redis.php:32 Stack trace: #0 [..]/redis.php(32): Redis->ping() #1 {main} thrown in [..]/redis.php on line 32
the only thing I could find on Google was the timeout settings, which did not work. I've tried several image versions, alpine, latest, 5.0.8; all the same error.
Does anyone know what's going on here?