phpredis
phpredis copied to clipboard
PHP Notice: Redis::set(): send of 36 bytes failed with errno=32 Broken pipe in
Expected behaviour
throw redis exception
Actual behaviour
return FALSE
I'm seeing this behaviour on
- OS: centos 6.9
- Redis:3.2.3
- PHP:7.1.7
- phpredis:3.1.3
Steps to reproduce, backtrace or example script
when the redis connected and network not good. sending cmd or reciveing network down phpredis will return false not throw exception
I've checked
- [x] There is no similar issue from other users ,
have same but i found a little different
- [x] Issue isn't fixed in
develop
branch sure
@xcl3721 why do you think it should throws an exception? Do you have a script to reproduce this issue?
And if you have tested latest version of phpredis next time please set correct value in I'm seeing this behaviour on
i can't check if it's work well when the connection not work. for example get one not exist key will return false and only ping cmd befor can check if the connection is well
another version introduce when the connection is down get an exist key will return false. but the key exist!
now when an execute an command i run ping cmd first ...
This is very dangerous and gives false positives about records not existing. I have seen this in phpredis 4.2.0 using hGetAll() and get(). If "false" is supposed to mean that a key was not found, I would expect that I can safely assume that the key doesn't exist, and perhaps write new data to that key. This should definitely be an exception.
I found that using multi(Redis::PIPELINE) / exec is also another way to deal with the issue in one request (rather than an extra request for ping()), as it returns false in this case instead of an array. Then do a close() if the response was false (for pconnect, using close() only applies to version 4.2.0 and above).
H All,
I am getting errors similar to above -
ProductImport.CRITICAL: Notice: Redis::hGet(): send of 63 bytes failed with errno=32 Broken pipe in
What could be the cause? Is it due to lost connection or something else?? Any redis parameter or php parameter to modify?
Same errors here.
[2020-08-12 10:42:55] local.ERROR: Redis::eval(): send of 889 bytes failed with errno=32 Broken pipe {"exception":"[object] (ErrorException(code: 0): Redis::eval(): send of 889 bytes failed with errno=32 Broken pipe at
@NimishKmr @digitalhuman could you provide more information?
@NimishKmr @digitalhuman could you provide more information?
Hi @yatsukhnenko , We are using redis with Magento2.2. Redis version - 3.2.11 The error is shown in our logs, and its intermittent. But happen frequently. What more info do you need, I am happy to share.
Regards, Nimish
@NimishKmr what version of phpredis do you use?
In case it might help with debugging: We've observed this problem on platforms where connections are dropped silently after a few minutes of inactivity (for Azure, the limit is about 4 minutes). In our case (phpredis: 5.3.1, php7.3.22, redis 4) the problem went away after setting tcp-keepalive to 120 and timeout to 180 on our server, as well as setting OPT_TCP_KEEPALIVE on the client.
Any solutions for this issue?
Use PECL PHP Redis. @LeVadim
@digitalhuman Thank you for the swift response. Currently I am installing PHP redis on ubuntu by install php7.4-redis package, this issue persists. Can you please advise here? Many thanks!
Did you disable flushing to disk? Is it a heavy load server?
I have updated it to php8.0-redis, issue still persists. Can please advise how to disable flushing to disk? It is pretty heavy load server, however, it has enough CPU and memory.
phpredis exception in windows :Redis::eval():send of 646 bytes failed with errno=10054
how to fix?
Redis::hGet(): send of 51 bytes failed with errno=32 Broken pipe phpredis 5.3.7
Receiving the errors on random occasions - might be related to heavy load, but I am not sure.
Hello, there!
As we investigated with the team, the "Broken pipe" error with horizon connections drops when Redis server exceeds the maximum clients (connections)
This limit defines in redis.conf file by "maxclients" field. If any value is not specified default one will be used, which 10000
So, for fixing this issue will be enough to increase the max number of clients (connections). it can be done by several ways:
- limit can be changed in redis.conf (e.g. maxclients 20000)
- with redis-cli
config set maxclients 20000
command - on redis-server startup, with
redis-server --maxclients 20000
Useful sources: https://linuxhint.com/max-connections-reddis/ https://stackoverflow.com/questions/51517578/how-many-total-connection-or-max-connections-are-available-in-redis-server (edited)
provide fake code for console script it's work well
redis obj proxy class __call(){
if $lastPingTime + 200 second < now() {
if (Redis->ping() != "pong" ) {
conn.close(true)
reconnect
$lastPingTime = now();
}
}
Мне помогло exec() и try/catch. Такие ошибки у меня т.к. расширение redis есть в php, но СУБД не установлена на сервере.
try {
$redis = new \Redis();
$redis->pconnect(CACHE_HOSTNAME, CACHE_PORT);
//$redis->auth(CACHE_PASSWORD);
} catch (\Exception $e) {
$active = false;
echo 'Message Redis: ' . $e->getMessage() . '<br>';
} catch (\RedisException $e) {
$active = false;
echo 'Message Redis: ' . $e->getMessage() . '<br>';
} finally {
if ($redis->exec() && $redis->isConnected() && $redis->getHost()) {
$active = true;
} else {
$active = false;
}
}