From 900dfbd4fba407115935519c76921fbe23c3d612 Mon Sep 17 00:00:00 2001 From: Rui Campos Date: Fri, 21 Apr 2017 17:47:13 +0100 Subject: [PATCH] SMK-1394: Infinite loop on close connection This is affecting consumers when it takes more than 2*heartbeat time to process a message. When trying to close the connection, library will: * check the heartbeat * detect that it passed more than 2*times the heartbeat value without receiving anything * considers that server has gone away and tries to reconnect * after reconnecting as it is not clearing internal variables with time of last read, it will check the heartbeat again and try to reconnect again in loop. There are already issues on the library's github: https://github.com/php-amqplib/php-amqplib/issues/309 and https://github.com/php-amqplib/php-amqplib/issues/413 --- PhpAmqpLib/Wire/IO/StreamIO.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/PhpAmqpLib/Wire/IO/StreamIO.php b/PhpAmqpLib/Wire/IO/StreamIO.php index 68278bcdf..9e3b34453 100644 --- a/PhpAmqpLib/Wire/IO/StreamIO.php +++ b/PhpAmqpLib/Wire/IO/StreamIO.php @@ -353,6 +353,9 @@ public function close() fclose($this->sock); } $this->sock = null; + // Reset last_read and last_write + $this->last_read = null; + $this->last_write = null; } /**