Skip to content

Commit 2d9bdc0

Browse files
Merge branch '6.0' into 6.1
* 6.0: [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 7fafcd3 + 7ecbb5c commit 2d9bdc0

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
@@ -91,6 +91,11 @@ class Connection
9191

9292
private \AMQPExchange $amqpDelayExchange;
9393

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

340+
$this->lastActivityTime = time();
341+
335342
$exchange->publish(
336343
$body,
337344
$routingKey,
@@ -495,6 +502,11 @@ static function (): bool {
495502
}
496503
);
497504
}
505+
506+
$this->lastActivityTime = time();
507+
} elseif (0 < ($this->connectionOptions['heartbeat'] ?? 0) && time() > $this->lastActivityTime + 2 * $this->connectionOptions['heartbeat']) {
508+
$disconnectMethod = 'true' === ($this->connectionOptions['persistent'] ?? 'false') ? 'pdisconnect' : 'disconnect';
509+
$this->amqpChannel->getConnection()->{$disconnectMethod}();
498510
}
499511

500512
return $this->amqpChannel;

0 commit comments

Comments
 (0)