Skip to content

Commit

Permalink
Merge pull request jakubkulhan#126 from roman-huliak/patch-1
Browse files Browse the repository at this point in the history
Call HB if communication is still active
  • Loading branch information
WyriHaximus authored Dec 12, 2022
2 parents ee8777b + 1e56537 commit cd7067e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Bunny/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,10 @@ public function run($maxSeconds = null)
} else {
if (($frame = $this->reader->consumeFrame($this->readBuffer)) === null) {
$now = microtime(true);
$nextStreamSelectTimeout = $nextHeartbeat = ($this->lastWrite ?: $now) + $this->options["heartbeat"];
$nextStreamSelectTimeout = ($this->lastWrite ?: $now) + $this->options["heartbeat"];
if (!isset($nextHeartbeat)) {
$nextHeartbeat = $now + $this->options["heartbeat"];
}
if ($stopTime !== null && $stopTime < $nextStreamSelectTimeout) {
$nextStreamSelectTimeout = $stopTime;
}
Expand Down Expand Up @@ -224,6 +227,7 @@ public function run($maxSeconds = null)
$now = microtime(true);

if ($now >= $nextHeartbeat) {
$nextHeartbeat = $now + $this->options["heartbeat"];
$this->writer->appendFrame(new HeartbeatFrame(), $this->writeBuffer);
$this->flushWriteBuffer();

Expand Down

0 comments on commit cd7067e

Please sign in to comment.