code: @SuppressWarnings("unchecked")
    private <T extends Request> void resendRequest(Throwable cause, T request, BiFunction sender, Connection connection, CompletableFuture future) {
      // If the connection has not changed, reset it and connect to the next server.
      if (this.connection == connection) {
        LOGGER.trace("{} - Resetting connection. Reason: {}", id, cause);
        this.connection = null;
        connection.close();
      }
  
      // Create a new connection and resend the request. This will force retries to piggyback on any existing
      // connect attempts.
      connect().whenComplete((c, e) -> sendRequest(request, sender, c, e, future));
    }
docs: Resends a request due to a request failure, resetting the connection if necessary.