public void onFailedAttempt(final long currentTimeMs) {
            // Reset timer to allow sending HB after a failure without waiting for the interval.
            // After a failure, a next HB may be needed with backoff (ex. errors that lead to
            // retries, like coordinator load error), or immediately (ex. errors that lead to
            // rejoining, like fencing errors).
            heartbeatTimer.reset(0);
            super.onFailedAttempt(currentTimeMs);
        }
Check if a heartbeat request should be sent on the current time. A heartbeat should be
sent if the heartbeat timer has expired, backoff has expired, and there is no request
in-flight.
clients/src/main/java/org/apache/kafka/clients/consumer/internals/HeartbeatRequestManager.java