phpredis icon indicating copy to clipboard operation
phpredis copied to clipboard

PHP Notice: Redis::set(): send of 36 bytes failed with errno=32 Broken pipe in

Open 137-rick opened this issue 6 years ago • 21 comments

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

137-rick avatar Nov 05 '18 05:11 137-rick

@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

yatsukhnenko avatar Nov 05 '18 12:11 yatsukhnenko

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

137-rick avatar Nov 06 '18 09:11 137-rick

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 ...

137-rick avatar Jan 03 '19 10:01 137-rick

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.

mdurn avatar Feb 14 '19 11:02 mdurn

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).

mdurn avatar Feb 15 '19 00:02 mdurn

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 /vendor/colinmollenhour/credis/Client.php on line 1139 []

What could be the cause? Is it due to lost connection or something else?? Any redis parameter or php parameter to modify?

NimishKmr avatar Jul 31 '20 14:07 NimishKmr

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

digitalhuman avatar Aug 12 '20 10:08 digitalhuman

@NimishKmr @digitalhuman could you provide more information?

yatsukhnenko avatar Aug 29 '20 16:08 yatsukhnenko

@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 avatar Sep 02 '20 06:09 NimishKmr

@NimishKmr what version of phpredis do you use?

yatsukhnenko avatar Sep 02 '20 07:09 yatsukhnenko

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.

cfroystad avatar Sep 14 '20 06:09 cfroystad

Any solutions for this issue?

LeVadim avatar Feb 15 '21 20:02 LeVadim

Use PECL PHP Redis. @LeVadim

digitalhuman avatar Feb 16 '21 07:02 digitalhuman

@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!

LeVadim avatar Feb 18 '21 21:02 LeVadim

Did you disable flushing to disk? Is it a heavy load server?

digitalhuman avatar Feb 19 '21 07:02 digitalhuman

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.

LeVadim avatar Feb 19 '21 17:02 LeVadim

phpredis exception in windows :Redis::eval():send of 646 bytes failed with errno=10054

how to fix?

BinZhiZhu avatar Jun 11 '21 03:06 BinZhiZhu

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. obraz

marcing avatar Oct 10 '22 13:10 marcing

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)

lov3g00d avatar Feb 15 '23 16:02 lov3g00d

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();
    }
}

137-rick avatar Mar 01 '23 02:03 137-rick

Мне помогло 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;
			}
		}

BuslikDrev avatar Apr 25 '23 00:04 BuslikDrev