Skip to content

Commit

Permalink
Merge pull request #120 from viras777/master
Browse files Browse the repository at this point in the history
Fix drop connection by RabbitMQ
  • Loading branch information
WyriHaximus authored May 19, 2024
2 parents 6cdf0ed + 96b55f6 commit 4842701
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/Bunny/Async/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,16 @@ public function addAwaitCallback(callable $callback)
*/
public function onDataAvailable()
{
$this->read();
try {
$this->read();
} catch (\Throwable $e) {
foreach ($this->awaitCallbacks as $k => $callback) {
if ($callback($e) === true) {
unset($this->awaitCallbacks[$k]);
break;
}
}
}

while (($frame = $this->reader->consumeFrame($this->readBuffer)) !== null) {
foreach ($this->awaitCallbacks as $k => $callback) {
Expand Down
2 changes: 1 addition & 1 deletion src/Bunny/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public function run($maxSeconds = null)
$now = microtime(true);
$nextStreamSelectTimeout = ($this->lastWrite ?: $now) + $this->options["heartbeat"];
if (!isset($nextHeartbeat)) {
$nextHeartbeat = $now + $this->options["heartbeat"];
$nextHeartbeat = $nextStreamSelectTimeout;;
}
if ($stopTime !== null && $stopTime < $nextStreamSelectTimeout) {
$nextStreamSelectTimeout = $stopTime;
Expand Down

0 comments on commit 4842701

Please sign in to comment.