code: private void handleConnection(Address address, Connection connection, Throwable error, CompletableFuture<Connection> future) {
      if (open) {
        if (error == null) {
          setupConnection(address, connection, future);
        } else {
          LOGGER.debug("{} - Failed to connect! Reason: {}", id, error);
          connect(future);
        }
      }
    }
docs: Handles a connection to a server.