cancel
Showing results for 
Search instead for 
Did you mean: 
Login & Join the DevCentral Connects Group to watch the Recorded LiveStream (May 12) on Basic iControl Security - show notes included.
Nat_Thirasutta3
F5 Employee
F5 Employee

Problem this snippet solves:

When limit is set on pool member, OneConnect is used and number of busy server connection reaches the limit client connection which sends new HTTP request will be reset. (for OneConnect, actual limit is the limit configured minus 1)

This iRule uses LB_FAILED to intercept such situation and uses "after" command (introduced in v10) to put 2 milliseconds delay before attempting to send HTTP::request again using HTTP::retry.

Code :

when RULE_INIT {
    set static::pause 2
}
when CLIENT_ACCEPTED {
    set self 0
    if {  [IP::client_addr] eq "127.127.127.127" } {
        TCP::collect
    } else {
        set original_snat [LB::snat]
    }
}
when CLIENT_DATA {
    TCP::payload replace 0 [TCP::payload length] ""
after $static::pause "TCP::respond \"HTTP/1.1 555 NotOK\\r\\nConnection: close\\r\\n\\r\\n\""
after 200 "TCP::close"
    TCP::collect
}
when HTTP_REQUEST {
    eval $original_snat
    switch [HTTP::method] {
        "POST" -
        "PUT" {
            HTTP::collect [HTTP::header Content-Length]
        }
        default {
            set request [HTTP::request]
        }
    }
}
when HTTP_REQUEST_DATA {
    set request [HTTP::request][HTTP::payload [HTTP::header Content-Length]]
}
when HTTP_RESPONSE {
if { [HTTP::status] == 555 } {
HTTP::retry $request
}
}
when LB_FAILED {
    snat 127.127.127.127
    LB::reselect virtual [virtual]
}
Version history
Last update:
‎17-Mar-2015 17:15
Updated by:
Contributors