Skip to content

Commit cd7067e

Browse files
authored
Merge pull request #126 from roman-huliak/patch-1
Call HB if communication is still active
2 parents ee8777b + 1e56537 commit cd7067e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: src/Bunny/Client.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,10 @@ public function run($maxSeconds = null)
189189
} else {
190190
if (($frame = $this->reader->consumeFrame($this->readBuffer)) === null) {
191191
$now = microtime(true);
192-
$nextStreamSelectTimeout = $nextHeartbeat = ($this->lastWrite ?: $now) + $this->options["heartbeat"];
192+
$nextStreamSelectTimeout = ($this->lastWrite ?: $now) + $this->options["heartbeat"];
193+
if (!isset($nextHeartbeat)) {
194+
$nextHeartbeat = $now + $this->options["heartbeat"];
195+
}
193196
if ($stopTime !== null && $stopTime < $nextStreamSelectTimeout) {
194197
$nextStreamSelectTimeout = $stopTime;
195198
}
@@ -224,6 +227,7 @@ public function run($maxSeconds = null)
224227
$now = microtime(true);
225228

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

0 commit comments

Comments
 (0)