ltm rule command afterΒΆ

iRule(1)		      BIG-IP TMSH Manual		      iRule(1)



after
       Execute iRules code after a set period of delay.

SYNOPSIS
       after MILLI_SECONDS (-periodic)? (NESTING_SCRIPT)?

   DESCRIPTION
       Delays rule execution for the given milliseconds. If SCRIPT parameter
       is given, schedules it for execution after the given milliseconds.  If
       -periodic switch is supplied, the script will be evaluated every given
       milliseconds.

       after cancel (-current | (ID)+)

   DESCRIPTION
       Cancels the scheduled evaluation of the scripts identified by .
       When -current is supplied from within after script, cancel the periodic
       timer of the active script.

       after info (ID)*

   DESCRIPTION
       Returns information about currently scheduled scripts, or about the
       script of the given id.

DESCRIPTION
       The after command allows you to insert a delay into the processing of
       your iRule, executing the specified script after a certain amount of
       time has passed. It also allows for things like periodic (repeat)
       execution of a script, as well as looking up or canceling currently
       delayed scripts.

       Note: The after command is not available in GTM.

RETURN VALUE
       When script is named, an id is returned for the script.

VALID DURING
       RULE_INIT

EXAMPLES
	when RULE_INIT {
	   set users_last_sec 0
	   set new_user_count 0
	   after 1000 AXCperiodic {
	      set users_last_sec $new_user_count
	      set new_user_count 0
	   }
	}

	when HTTP_REQUEST {
	   if {not [HTTP::cookie exists UserID]} {
	      incr new_user_count
	   }
	   if {[expr {$users_last_sec + $new_user_count}] > 500} {
	      HTTP::respond 503 Retry-After 3
	   }
	}


	# send response from BigIP if server does not respond within a specified amount of time.
	when RULE_INIT {
	    # Timeout is in Milliseconds
	    set static::response_timeout  10000
	    }

	    when HTTP_REQUEST {
		log local0. "Received request, beginning response monitor interval. [clock seconds]"
		set monitor_id [\
		    after $static::response_timeout {
			log local0. "Timeout $static::response_timeout	milliseconds elapsed without server response. [clock seconds]"
			TCP::respond "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nContent-Length: 69\r\n\r\n We are responding because server was late."
		    }\
		 ]
	    }

	    when HTTP_RESPONSE {
		log local0. "Received server response. "
		if {[info exists monitor_id]} {
		    log local0. "Canceling after script with id $monitor_id"
		    after cancel $monitor_id
		}
	    }


	 # Close the client connection after X seconds no matter how long it's idle for
	 when RULE_INIT {
	     # Timeout is in milliseconds
	     set static::response_timeout 10000
	 }

	 when CLIENT_ACCEPTED {
	     log local0. "Received connection, beginning timer for $static::response_timeout from [clock seconds]"
	     after $static::response_timeout {
		 log local0. "Timeout $static::response_timeout milliseconds elapsed closing connection. [clock seconds]"
		 reject
	     }
	 }

HINTS
SEE ALSO
        

CHANGE LOG
       @BIGIP-10.0.0 --First introduced the command.



BIG-IP				  2017-01-31			      iRule(1)