Skip to content

Commit 4842701

Browse files
authored
Merge pull request #120 from viras777/master
Fix drop connection by RabbitMQ
2 parents 6cdf0ed + 96b55f6 commit 4842701

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Diff for: src/Bunny/Async/Client.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,16 @@ public function addAwaitCallback(callable $callback)
297297
*/
298298
public function onDataAvailable()
299299
{
300-
$this->read();
300+
try {
301+
$this->read();
302+
} catch (\Throwable $e) {
303+
foreach ($this->awaitCallbacks as $k => $callback) {
304+
if ($callback($e) === true) {
305+
unset($this->awaitCallbacks[$k]);
306+
break;
307+
}
308+
}
309+
}
301310

302311
while (($frame = $this->reader->consumeFrame($this->readBuffer)) !== null) {
303312
foreach ($this->awaitCallbacks as $k => $callback) {

Diff for: src/Bunny/Client.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public function run($maxSeconds = null)
191191
$now = microtime(true);
192192
$nextStreamSelectTimeout = ($this->lastWrite ?: $now) + $this->options["heartbeat"];
193193
if (!isset($nextHeartbeat)) {
194-
$nextHeartbeat = $now + $this->options["heartbeat"];
194+
$nextHeartbeat = $nextStreamSelectTimeout;;
195195
}
196196
if ($stopTime !== null && $stopTime < $nextStreamSelectTimeout) {
197197
$nextStreamSelectTimeout = $stopTime;

0 commit comments

Comments
 (0)