private function checkForConnectionErrors(int $errorCode, string $errorDescription): self
    {
        if ($errorCode !== 0 || $this->socket === null) {
            $this->logger->critical('Could not connect to broker', [
                'errorCode' => $errorCode,
                'errorDescription' => $errorDescription,
            ]);

            throw new NotConnected('Could not connect to broker: ' . $errorDescription, $errorCode);
        }

        return $this;
    }