private function completePossibleIncompleteMessage(string $rawMQTTHeaders, ClientInterface $client): string
    {
        // Read at least one extra byte from the stream if we know that the message is too short
        if (strlen($rawMQTTHeaders) < 2) {
            $rawMQTTHeaders .= $client->readBrokerData(1);
        }

        $restOfBytes = $this->performRemainingLengthFieldOperations($rawMQTTHeaders, $client);

        /*
         * A complete message consists of:
         *  - The very first byte
         *  - The size of the remaining length field (from 1 to 4 bytes)
         *  - The $restOfBytes
         *
         * So we have to compare what we already have vs the above calculation
         *
         * More information:
         * http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/errata01/os/mqtt-v3.1.1-errata01-os-complete.html#_Toc442180832
         */
        if (strlen($rawMQTTHeaders) < ($restOfBytes + $this->sizeOfRemainingLengthField + 1)) {
            // Read only the portion of data we have left from the socket
            $readableDataLeft = ($restOfBytes + $this->sizeOfRemainingLengthField + 1) - strlen($rawMQTTHeaders);
            $rawMQTTHeaders .= $client->readBrokerData($readableDataLeft);
        }

        return $rawMQTTHeaders;
    }