Skip to content

Commit

Permalink
Fix infinite loop on reconnect - check_heartbeat
Browse files Browse the repository at this point in the history
The problem this PR fixes is:
* StreamConnection with heartbeat is created (e.g. heartbeat=10 seconds)
* Start consuming messages from the queue
* If one of the messages take more than 2*heartbeat interval to process (e.g. 30 seconds), the next time it tries to read something from Rabbit it will check_heartbeat()
* As it finds that it passed more than 2*heartbeat, it will reconnect()
* But as it does not reset the values of last_read and last_write, after reconnect it will do the check_heartbeat() again and as it is based on last_read, it will try to reconnect again
* It keeps trying to reconnect in infinite loop

This PR fixes issues: php-amqplib#413 and php-amqplib#309
  • Loading branch information
ruicampos committed Apr 21, 2017
1 parent 1822b6d commit 712f335
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions PhpAmqpLib/Wire/IO/StreamIO.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ public function close()
fclose($this->sock);
}
$this->sock = null;
$this->last_read = null;
$this->last_write = null;
}

/**
Expand Down

0 comments on commit 712f335

Please sign in to comment.