Disque\Connection\Node\Node::connect PHP Method

connect() public method

This method is idempotent and can be called multiple times
public connect ( ) : array
return array The HELLO response
    public function connect()
    {
        if ($this->connection->isConnected() && !empty($this->hello)) {
            return $this->hello;
        }
        $this->connectToTheNode();
        $this->authenticateWithPassword();
        try {
            $this->sayHello();
        } catch (ResponseException $e) {
            /**
             * If the node requires a password but we didn't supply any,
             * Disque returns a message "NOAUTH Authentication required"
             *
             * HELLO is the first place we would get this error.
             *
             * @see https://github.com/antirez/disque/blob/master/src/server.c
             * Look for "noautherr"
             */
            $message = $e->getMessage();
            if (stripos($message, self::AUTH_REQUIRED_MESSAGE) === 0) {
                throw new AuthenticationException($message);
            }
        }
        return $this->hello;
    }