Hi James,
That's a nice rule to start with...
You could try to track each server that's been requested and failed, but that's going to get expensive in terms of memory and CPU to process the used members for every request which generates a 404. If you wanted to try, you could use [active_members -list] (
Click here) if you're running 9.4.2 or higher. You'd need to save the available members to a list and then move them to a tried/failed list.
Also, HTTP::request only returns the HTTP headers from a request. And it would be very expensive in terms of memory to try to collect every request payload to potentially use if there is a 404 response. So you might be better off checking the request method using HTTP::method and only saving the request headers for GET requests. You could then add a check in HTTP_RESPONSE for a 404 status to a GET request:
when CLIENT_ACCEPTED {
set retries 0
}
when HTTP_REQUEST {
if {[HTTP::method] eq "GET"}{
Save the request headers
set request [HTTP::request]
} else {
Not going to retry this request, so unset the variable
unset request
}
}
when HTTP_RESPONSE {
Check if the response is a 404 and it was a response to a GET request
if { [HTTP::status] == 404 && [info exists request]} {
Check if we've tried fewer times than number of pool members
if { $retries < [active_members mediapool] } {
Retry request
incr retries
HTTP::retry $request
} else {
Give up and send a 404
We could just do nothing and send back the application's response...
HTTP::respond 404
}
}
}
Aaron