Expose a way to modify the APIM idle timeout or tcp keep alive settings
I have several legacy, long-running, synchronous API operations (10+ mins) that never get a response when I route them through APIM. This is because APIM does not maintain that TCP connection long enough for the backend server to compile the response.
A quick response is to make them asynchronous, which I would have done from the beginning had I designed and developed this product, but as I said this is a legacy application with many existing clients and to change the architecture of this now is not really feasible.
I have worked with Todd Foust from Micorsoft support to determine that the issue is indeed with Azure closing this connection and the ticket has specific details and examples of how to recreate this issue.
Bruno DEMEYERE commented
On a regular basis we have errors of type "BackendConnectionFailure/The underlying connection was closed: A connection that was expected to be kept alive was closed by the server".
It happens only on specific hosts (and some are not under our control).
I search for a way to avoid persistent connection with those host (or to be able to deal with keep-alive parameter at APIM side). Settting header "Connection" or "Keep-alive" are not allowed in APIM policies (it results an error when trying to save policy).
I think being able to set specifics connections settings on a per backend basis could be helpful to deal with those kind of errors.
Barry Lowrance commented
That probably will not work for anything longer than 4 minutes.
timeout="integer" The amount of time in seconds to wait for the HTTP response headers to be returned by the backend service before a timeout error is raised. Minimum value is 0 seconds. Values greater than 240 seconds may not be honored as the underlying network infrastructure can drop idle connections after this time.
I just found your post looking for an answer to the same question. What I found out is that you need to set a policy as follow:
<forward-request timeout="seconds" />
Just in case you still have the issue