diff --git a/phpMQTT.php b/phpMQTT.php index c028b0d..0815a23 100644 --- a/phpMQTT.php +++ b/phpMQTT.php @@ -431,7 +431,13 @@ public function publish($topic, $content, $qos = 0, $retain = false): void protected function _fwrite($buffer) { $buffer_length = strlen($buffer); + $overflowcounter = 0; for ($written = 0; $written < $buffer_length; $written += $fwrite) { + $overflowcounter++ ; + if ($overflowcounter > ($buffer_length * 2)){ + print "ERROR sending data in phpMQTT.php" . PHP_EOL; + return false; + } $fwrite = fwrite($this->socket, substr($buffer, $written)); if ($fwrite === false) { return false;