Skip to content

Commit d36c967

Browse files
authored
Disabled heartbeat in options (for non workers) (#36)
1 parent 4110a7e commit d36c967

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Remote/AMQP/Connector.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ public static function create(string $dsn): self
5050
parse_str($components['query'], $options);
5151
}
5252

53+
if (PHP_SAPI !== 'cli') {
54+
$options['heartbeat'] = 0;
55+
}
56+
5357
return new self([$components], $options);
5458
}
5559

@@ -62,7 +66,7 @@ public function connect(): AMQPChannel
6266
/** @var AMQPStreamConnection $connection */
6367
$connection = AMQPStreamConnection::create_connection($this->hosts, $this->options);
6468

65-
if (PHP_SAPI === 'cli' && $connection->getHeartbeat() > 0) {
69+
if ($connection->getHeartbeat() > 0) {
6670
$this->heartbeats = match ($this->options['heartbeat_sender'] ?? null) {
6771
'sig' => new Heartbeat\SIGHeartbeatSender($connection),
6872
default => new Heartbeat\PCNTLHeartbeatSender($connection),

0 commit comments

Comments
 (0)