2

We're having an issue with an AWS hosted .net core 3 application, getting intermittent 502 errors from the load balancer. The api is in a docker container and also hosts a react front-end. The issue is described well in the documentation:

We also recommend that you configure the idle timeout of your application to be larger than the idle timeout configured for the load balancer. Otherwise, if the application closes the TCP connection to the load balancer ungracefully, the load balancer might send a request to the application before it receives the packet indicating that the connection is closed. If this is the case, the server refuses the request from the load balancer and then the load balancer sends an HTTP 502 Bad Gateway error to the application.

The question I have is: how do I set that? Based on preliminary research, the timeout is set by the host: IIS, AWS, etc. That's what I'm seeing in testing. I made an api endpoint that just waits for 8 minutes as a test. Whatever I set the AWS Load balancer idle timeout to, that's how long it takes before getting a 504 gateway timeout. There appears to be no such thing as the application timing out separate from the AWS LB. at least not by default.

Do I need to add custom global code on top of my controllers to create my own application timeout? Or is there some other setting I'm not seeing?

Alex
  • 20,405
  • 4
  • 17
  • 22
  • If you're using Docker I'm guessing you would be using Kestral to host the application? https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel/options?view=aspnetcore-6.0 *Keep idle connections alive. Some clients and proxy servers close connections that are idle. HTTP/2 pings are considered as activity on a connection and prevent the connection from being closed as idle.* – Jeremy Thompson Jul 19 '22 at 00:35

0 Answers0