public function createConnection($maxAttempts = 3)
    {

        if (is_null($this->connection)) {
            $lastExcelption = $this->attemptConnection($maxAttempts);

            if (!is_null($lastExcelption)) {
                $this->console->getSfStyleOutput()->error(
                    [
                        "Looks like your Dedicated server is either offline or has wrong config settings",
                        "Error message: " . $lastExcelption->getMessage()
                    ]
                );
                $this->logger->error("Unable to open connection for Dedicated server", ["exception" => $lastExcelption]);

                throw $lastExcelption;
            }

            // Dispatch connected event.
            $event = new GenericEvent($this->connection);
            $this->eventDispatcher->dispatch(self::EVENT_CONNECTED, $event);
        }

        return $this->connection;
    }