0

We have a backend service currently served in front of a HAProxy proxy server for load balancing.

When we shut down the backend service for maintenance, client connecting to the HAProxy is receiving 504-Gateway Timeout error, which is expected.

However when the backend service is up, the client continue to receive the 504 status code, well into the next day after.

Client is connecting via a connection pool, using Spring RestTemplate and Apache HTTPClient.

After client is restarted, the problem goes away. Is there any configuration in HAProxy that caches the connection? Any configuration that we can do to prevent this issue?

Note that if try manually using curl command, the request can reach the backend without issue.

Thank you.

ipohfly
  • 115
  • 6

1 Answers1

0

This can happen if caching-related headers such as Expires: are set blindly, irrespective of whether HAProxy is returning content or an error to the client. What happens if the client's cache/site data is cleared?

Look at the headers being returned to the browser, e.g. using developer mode on Firefox or Chrome. If HAProxy is returning cache information for the error, it should either not be added, stripped or shortened. Add the headers to your question if needed.

tater
  • 1,445
  • 2
  • 10
  • 12
  • The Service is actually a REST API call, while the client is using RestTemplate and not a browser. Will the `Expires` header affect the behaviour? – ipohfly Nov 09 '20 at 08:11
  • A client-side cache would depend on the implementation (but less likely than a regular browser, so the cause may be elsewhere); server side if you've got `http-request cache-use` then it would affect all clients. – tater Nov 09 '20 at 09:34