Skip to content

Commit 8d6ecd8

Browse files
authored
Fix: auto-reconnect on read if configured (#131)
1 parent 10750d8 commit 8d6ecd8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/MqttClient.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ public function loopOnce(float $loopStartedAt, bool $allowSleep = false, int $sl
668668
$this->runLoopEventHandlers($elapsedTime);
669669

670670
// Read data from the socket - as much as available.
671-
$this->buffer .= $this->readAllAvailableDataFromSocket();
671+
$this->buffer .= $this->readAllAvailableDataFromSocket(true);
672672

673673
// Try to parse a message from the buffer and handle it, as long as messages can be parsed.
674674
if (strlen($this->buffer) > 0) {
@@ -1257,7 +1257,7 @@ protected function readAllAvailableDataFromSocket(bool $withAutoReconnectIfConfi
12571257
$result = '';
12581258

12591259
while (true) {
1260-
$buffer = $withAutoReconnectIfConfigured
1260+
$buffer = ($withAutoReconnectIfConfigured && $this->settings->shouldReconnectAutomatically())
12611261
? $this->readFromSocketWithAutoReconnect(self::SOCKET_READ_BUFFER_SIZE, true)
12621262
: $this->readFromSocket(self::SOCKET_READ_BUFFER_SIZE, true);
12631263

0 commit comments

Comments
 (0)