Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bdeef74

Browse filesBrowse files
GurvanVgxsurfingmig
authored andcommitted
[Messenger] Fix amqp socket lost
Co-authored-by: Miguel Fernandez <mfernandez@nuglif.com>
1 parent 3b17a0c commit bdeef74
Copy full SHA for bdeef74

File tree

Expand file treeCollapse file tree

1 file changed

+12
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+12
-0
lines changed

‎src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ class Connection
102102
*/
103103
private $amqpDelayExchange;
104104

105+
/**
106+
* @var int
107+
*/
108+
private $lastActivityTime = 0;
109+
105110
public function __construct(array $connectionOptions, array $exchangeOptions, array $queuesOptions, AmqpFactory $amqpFactory = null)
106111
{
107112
if (!\extension_loaded('amqp')) {
@@ -347,6 +352,8 @@ private function publishOnExchange(\AMQPExchange $exchange, string $body, string
347352
$attributes['delivery_mode'] = $attributes['delivery_mode'] ?? 2;
348353
$attributes['timestamp'] = $attributes['timestamp'] ?? time();
349354

355+
$this->lastActivityTime = time();
356+
350357
$exchange->publish(
351358
$body,
352359
$routingKey,
@@ -510,6 +517,11 @@ static function (): bool {
510517
}
511518
);
512519
}
520+
521+
$this->lastActivityTime = time();
522+
} elseif (0 < ($this->connectionOptions['heartbeat'] ?? 0) && time() > $this->lastActivityTime + 2 * $this->connectionOptions['heartbeat']) {
523+
$disconnectMethod = 'true' === ($this->connectionOptions['persistent'] ?? 'false') ? 'pdisconnect' : 'disconnect';
524+
$this->amqpChannel->getConnection()->{$disconnectMethod}();
513525
}
514526

515527
return $this->amqpChannel;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.