Skip to content

Commit 7ecbb5c

Browse files
Merge branch '5.4' into 6.0
* 5.4: [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 [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 0a17611 + 8775f97 commit 7ecbb5c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Transport/Connection.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ class Connection
9090

9191
private $amqpDelayExchange;
9292

93+
/**
94+
* @var int
95+
*/
96+
private $lastActivityTime = 0;
97+
9398
public function __construct(array $connectionOptions, array $exchangeOptions, array $queuesOptions, AmqpFactory $amqpFactory = null)
9499
{
95100
if (!\extension_loaded('amqp')) {
@@ -331,6 +336,8 @@ private function publishOnExchange(\AMQPExchange $exchange, string $body, string
331336
$attributes['delivery_mode'] = $attributes['delivery_mode'] ?? 2;
332337
$attributes['timestamp'] = $attributes['timestamp'] ?? time();
333338

339+
$this->lastActivityTime = time();
340+
334341
$exchange->publish(
335342
$body,
336343
$routingKey,
@@ -494,6 +501,11 @@ static function (): bool {
494501
}
495502
);
496503
}
504+
505+
$this->lastActivityTime = time();
506+
} elseif (0 < ($this->connectionOptions['heartbeat'] ?? 0) && time() > $this->lastActivityTime + 2 * $this->connectionOptions['heartbeat']) {
507+
$disconnectMethod = 'true' === ($this->connectionOptions['persistent'] ?? 'false') ? 'pdisconnect' : 'disconnect';
508+
$this->amqpChannel->getConnection()->{$disconnectMethod}();
497509
}
498510

499511
return $this->amqpChannel;

0 commit comments

Comments
 (0)