Keep alive period is measured in positive seconds. The maximum is 18h, 12m and 15s, equivalent to 65535 seconds

@param int $keepAlivePeriod
@return Parameters
@throws \InvalidArgumentException
977899
public function setKeepAlivePeriod(int $keepAlivePeriod): self
    {
        if ($keepAlivePeriod > 65535 || $keepAlivePeriod < 0) {
            $this->logger->error('Keep alive period must be between 0 and 65535');
            throw new \InvalidArgumentException('Keep alive period must be between 0 and 65535');
        }

        $this->keepAlivePeriod = $keepAlivePeriod;
        return $this;
    }
281161
@Override
  public OkHttpChannelBuilder keepAliveTime(long keepAliveTime, TimeUnit timeUnit) {
    Preconditions.checkArgument(keepAliveTime > 0L, "keepalive time must be positive");
    keepAliveTimeNanos = timeUnit.toNanos(keepAliveTime);
    keepAliveTimeNanos = KeepAliveManager.clampKeepAliveTimeInNanos(keepAliveTimeNanos);
    if (keepAliveTimeNanos >= AS_LARGE_AS_INFINITE) {
      // Bump keepalive time to infinite. This disables keepalive.
      keepAliveTimeNanos = KEEPALIVE_TIME_NANOS_DISABLED;
    }
    return this;
  }
811382
public static function keepalive()
	{
		if (isset(self::$loaded[__METHOD__]))
		{
			return;
		}

		self::framework();

		$lifetime    = (App::get('config')->get('lifetime') * 60000);
		$refreshTime = ($lifetime <= 60000) ? 30000 : $lifetime - 60000;

		// Refresh time is 1 minute less than the liftime assined in the configuration.php file.
		// the longest refresh period is one hour to prevent integer overflow.
		if ($refreshTime > 3600000 || $refreshTime <= 0)
		{
			$refreshTime = 3600000;
		}

		App::get('document')->addScriptDeclaration('
			jQuery(document).ready(function($){
				(function keepAlive() {
					$.ajax({
						url: "index.php",
						complete: function() {
							setTimeout(keepAlive, ' . $refreshTime . ');
						}
					});
				})();
			});'
		);

		self::$loaded[__METHOD__] = true;

		return;
	}
632110
protected function getRanges(\DatePeriod $period)
    {
        $ranges = array();

        $start = null;
        $end = null;
        $single = true;

        foreach ($period as $i => $date) {
            // Set single date
            $ranges[$i] = $date;

            // This is interval, so set it.
            if ($i > 0) {
                $ranges[$i - 1] = new DateRange($ranges[$i - 1], $date);
                $single = false;
            }
        }

        // Ranges are stored, so we don't need las element
        if (!$single) {
            array_pop($ranges);
        }

        return $ranges;
    }
960722
private function should_send_keepalive_update( $use_network_level_storage = null ) {
            $keepalive_timestamp = $this->_storage->get( 'keepalive_timestamp', 0, $use_network_level_storage );

            if ( $keepalive_timestamp < ( time() - WP_FS__TIME_WEEK_IN_SEC ) ) {
                // If updated more than 7 days ago, trigger a keepalive and update the time it was triggered.
                return true;
            } else {
                // If updated 7 days ago or less, "flip a coin", if the value is 7 trigger a keepalive and update the last time it was triggered.
                return ( 7 == rand( 1, 7 ) );
            }
        }
967261
def _keepalive(self):
        
        try:
            keptalive = False
            if self._customkeepalives:
                kaids = list(self._customkeepalives.keys())
                for keepalive in kaids:
                    try:
                        cmd, callback = self._customkeepalives[keepalive]
                    except TypeError:
                        # raw_command made customkeepalives None
                        break
                    except KeyError:
                        # raw command ultimately caused a keepalive to
                        # deregister
                        continue
                    if callable(cmd):
                        cmd()
                        continue
                    keptalive = True
                    cmd['callback'] = self._keepalive_wrapper(callback)
                    self.raw_command(**cmd)
            if not keptalive:
                if self.incommand:
                    # if currently in command, no cause to keepalive
                    return
                self.raw_command(netfn=6, command=1,
                                 callback=self._keepalive_wrapper(None))
        except exc.IpmiException:
            self._mark_broken()
893877
@Override
  public OkHttpChannelBuilder keepAliveTimeout(long keepAliveTimeout, TimeUnit timeUnit) {
    Preconditions.checkArgument(keepAliveTimeout > 0L, "keepalive timeout must be positive");
    keepAliveTimeoutNanos = timeUnit.toNanos(keepAliveTimeout);
    keepAliveTimeoutNanos = KeepAliveManager.clampKeepAliveTimeoutInNanos(keepAliveTimeoutNanos);
    return this;
  }
470732
public function keepalive($config = array())
    {
        $config = new ObjectConfigJson($config);
        $config->append(array(
            'refresh' => 15 * 60, //default refresh is 15min
            'url'     => '',      //default to window.location.url
        ));

        $html = '';

        // Only load once
        if (!static::isLoaded('keepalive'))
        {
            $session = $this->getObject('user')->getSession();
            if($session->isActive())
            {
                //Get the config session lifetime
                $lifetime = $session->getLifetime();

                //Refresh time is 1 minute less than the lifetime
                $refresh =  ($lifetime <= 60) ? 30 : $lifetime - 60;
            }
            else $refresh = (int) $config->refresh;

            // Longest refresh period is one hour to prevent integer overflow.
            if ($refresh > 3600 || $refresh <= 0) {
                $refresh = 3600;
            }

            if(empty($config->url)) {
                $url = 'window.location.url';
            } else {
                $url = "'.$config->url.'";
            }

            // Build the keep alive script.
            $html  = $this->jquery();
            $html .=
                "<script>
                (function($){
                    var refresh = '" . $refresh . "';
                    setInterval(function() {
                        $.ajax({
                            url: $url,
                            method: 'HEAD',
                            cache: false
                        })
                    }, refresh * 1000);
                })(kQuery);</script>";

            static::setLoaded('keepalive');
        }
        return $html;
    }
1067281
private void scheduleKeepAlive() {
    if (keepAlive != null)
      keepAlive.cancel();
    keepAlive = context.schedule(interval, () -> {
      keepAlive = null;
      if (state.getState().active()) {
        keepAlive();
      }
    });
  }
161528
public function setDuration($seconds)
    {
        $seconds = round($seconds, 3);

        if ($seconds < 0 || $seconds > 999999.999) {
            throw new InvalidArgumentException('Duration seconds must be in range 0-999999.999');
        }

        $this->duration = $seconds;

        return $this;
    }
894795
protected function _getDurationInSeconds($duration) {
        $interval = new \DateInterval($duration);
        return ($interval->d * 24 * 60 * 60) +
            ($interval->h * 60 * 60) +
            ($interval->i * 60) +
            $interval->s;
    }
126552
protected static function has_expired(string $period, int $comparisondate) : bool {
        $dt = new \DateTime();
        $dt->setTimestamp($comparisondate);
        $dt->add(new \DateInterval($period));

        return (time() >= $dt->getTimestamp());
    }
1159935
public GrpcServerBuilder keepAliveTime(long keepAliveTime, TimeUnit timeUnit) {
    mNettyServerBuilder = mNettyServerBuilder.keepAliveTime(keepAliveTime, timeUnit);
    return this;
  }
245945
public function period(string $period)
    {
        if (!in_array($period, Constants::PERIODS)) {
            throw new InvalidPeriodException('Request period is not valid. Valid values are defined in \Barryvanveen\Lastfm\Constants::PERIODS.');
        }

        $this->query = array_merge($this->query ?? [], ['period' => $period]);

        return $this;
    }
11686
public function add(/*\DateInterval*/ $interval) : \DateTime /*self invariant*/
    {
        // NB: Argument type hinting (\DateInterval $interval)
        // would provoke E_WARNING when cloning.
        // Catch 22: Specs say that native \DateTime method is type hinted,
        // but warning when cloning says it isn't.

        if ($this->frozen) {
            throw new \RuntimeException(get_class($this) . ' is read-only, frozen.');
        }
        return parent::add($interval);
    }
330733
public static void validatePeriod(Duration period) {
		if(period.equals(Duration.ZERO)) {
			String message = "The period must be nonzero";
			throw new IllegalArgumentException(message);
		}
	}
1239719
public function withIntervalInMonths($intervalInMonths)
    {
        $this->validateInterval($intervalInMonths);
        $this->interval = $intervalInMonths;
        $this->intervalUnit = IntervalUnit::MONTH;

        return $this;
    }