code: private void handleConnectResponse(ConnectResponse response, Throwable error, CompletableFuture<Connection> future) {
      if (open) {
        if (error == null) {
          LOGGER.trace("{} - Received {}", id, response);
          // If the connection was successfully created, immediately send a keep-alive request
          // to the server to ensure we maintain our session and get an updated list of server addresses.
          if (response.status() == Response.Status.OK) {
            selector.reset(response.leader(), response.members());
            future.complete(connection);
          } else {
            connect(future);
          }
        } else {
          LOGGER.debug("{} - Failed to connect! Reason: {}", id, error);
          connect(future);
        }
      }
    }
docs: Handles a connect response.