Forum Discussion
Oct 03, 2013
This one works a bit better with cookie persistence (plain OneConnect applied). But it still does a couple of reselects even it got a proper response, so I´m not fully happy yet.
Need to investigate a bit more (and build in a cookie decoding routine), but as I´m a freelancer I need to allocate time for it (hope for your understanding).when CLIENT_ACCEPTED {
set retry 0
set reselect 0
set default_pool [LB::server pool]
}
when HTTP_REQUEST {
if { ([HTTP::method] eq "GET") && ($retry == 0) } {
set request_headers [HTTP::request]
log local0. "Current retries of $retry for [HTTP::uri]"
} elseif { ([HTTP::method] eq "GET") && ($retry > 0) } {
persist none
}
}
when LB_SELECTED {
if { ($retry > 0) && ($reselect ==1) } {
log local0. "Re-loadbalancing to [LB::server] retries $retry [HTTP::uri]"
LB::reselect pool $default_pool
}
}
when HTTP_RESPONSE {
if { [HTTP::status] starts_with "5" } {
LB::down
set reselect 1
incr retry
log local0. "5xx error caught: retry $retry out of [active_members $default_pool]"
if { $retry < [active_members $default_pool] } {
log local0. "will retry now"
HTTP::retry $request_headers
return
}
} else {
persist cookie
set retry 0
set reselect 0
}
}