Skip to content

Commit 085ec59

Browse files
Merge branch '6.1' into 6.2
* 6.1: [HttpKernel] Fix empty request stack when terminating with exception [HttpKernel] Remove EOL when using error_log() in HttpKernel Logger [HttpClient] Add test case for seeking into the content of RetryableHttpClient responses [HttpClient] Fix buffering after calling AsyncContext::passthru() s/annd/and s/gargage/garbage [HttpClient] fix merge [HttpClient] Don't override header if is x-www-form-urlencoded [Console] Fix error output on windows cli Reserve keys when using numeric ones add missing Azerbaijani translations fix few typos/inconsistencies in latvian translations Fix TypeError in Router when using UrlGenerator [Messenger] Fix amqp socket lost fix: use message object from event
2 parents df1411f + 2d9bdc0 commit 085ec59

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Transport/Connection.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class Connection
9090
private array $amqpQueues = [];
9191

9292
private \AMQPExchange $amqpDelayExchange;
93+
private int $lastActivityTime = 0;
9394

9495
public function __construct(array $connectionOptions, array $exchangeOptions, array $queuesOptions, AmqpFactory $amqpFactory = null)
9596
{
@@ -332,6 +333,8 @@ private function publishOnExchange(\AMQPExchange $exchange, string $body, string
332333
$attributes['delivery_mode'] ??= 2;
333334
$attributes['timestamp'] ??= time();
334335

336+
$this->lastActivityTime = time();
337+
335338
$exchange->publish(
336339
$body,
337340
$routingKey,
@@ -495,6 +498,11 @@ static function (): bool {
495498
}
496499
);
497500
}
501+
502+
$this->lastActivityTime = time();
503+
} elseif (0 < ($this->connectionOptions['heartbeat'] ?? 0) && time() > $this->lastActivityTime + 2 * $this->connectionOptions['heartbeat']) {
504+
$disconnectMethod = 'true' === ($this->connectionOptions['persistent'] ?? 'false') ? 'pdisconnect' : 'disconnect';
505+
$this->amqpChannel->getConnection()->{$disconnectMethod}();
498506
}
499507

500508
return $this->amqpChannel;

0 commit comments

Comments
 (0)