DataScript: avi.http.set_server_timeout

DataScript

Function avi.http.set_server_timeout( time )
Description Set a custom timeout value for a particular request. By default, Avi allows a server one hour for its response, though clients will normally terminate a connection well before that. This timeout function is useful for high-speed trading applications, where a fast response is required, whether it is successful or not.

By default, Avi sends a 504 (gateway timeout) error on server timeout. To alter the error message Avi sends, add additional code to the HTTP_RESP_FAILED event. See the example below.

The timeout value specified by this function is applied in two ways. First, it is applied to the Server RTT, which measures how long it takes to establish a connection with the server. Separately, the same timeout value is also applied to the App Response time, which measures the time from last byte of the request leaving the Avi Service Engine until the first byte of the app response is received. If either time exceeds the timeout value, the client is sent a HTTP 504 response.

Features such as WAF inspection or HTTP request queuing do not have an impact on the time, as they happen prior to the request leaving the Service Engine.
Events HTTP_REQ
HTTP_RESP
Parameter time is the length of time, in milliseconds, in which a server connection be established and also the time until Avi receives the first byte of the response after sending the request.

Minimum value is 1.
No maximum length of time.
By default, Avi uses 3,600,000 ms (1 hour).
Returns No return value
Example Requests intended for high-frequency trading path have a strict 3-second timeout enforced while other paths do not.
- HTTP_REQ event
if string.beginswith(avi.http.get_path(), "/hft") then
avi.http.set_server_timeout(3000)
end

– HTTP_RESP_FAILED event
if avi.http.internal_status() == "504" then
avi.http.response(404,

{content_type="text/html"}
, "Server took too long to respond.")
end

Note: This API is not supported in the events SSL_PRECONNECT, SSL_CLIENTHELLO, and SSL_HANDSHAKE_DONE.