code: private void scheduleKeepAlive() {
      if (keepAlive != null)
        keepAlive.cancel();
      keepAlive = context.schedule(interval, () -> {
        keepAlive = null;
        if (state.getState().active()) {
          keepAlive();
        }
      });
    }
docs: Schedules a keep-alive request.