Azure App Service - prevent timeout after 230s

Arild Bjerkenes 1 Reputation point
2022-04-25T12:05:37.577+00:00

We have migrated a .net web-application to Azure App Service. Some requests may take longer than 230 seconds, and result in timeout. Is there any way to prevent this? We have tried to add <httpProtocol allowKeepAlive="true"> in the web-config, but with no luck. We know that we should reimplement the solution to avoid long running request, but this will take some time.

We have Azure Front door in front of the app-service.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,925 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. ajkuma 26,721 Reputation points Microsoft Employee
    2022-04-28T09:14:50.043+00:00

    @Arild Bjerkenes , Just following-up, as Alan mentioned, the timeout is not configurable, and cannot be changed.

    Just to highlight more on this, the 4-minute idle timeout on the TCP level and this is implemented on the Azure hardware load balancer. This timeout is not configurable, and this cannot be changed.
    Note that the idle timeout is at the TCP level which means that if the connection is idle only and no data transfer happening, then this timeout is hit.

    --Timeout will hit if the web application got the request and kept processing the request for > 4minutes without sending any data back.
    Ideally, in a web application, it is not good to keep the underlying HTTP request open and 4 minutes is a decent amount of time.

    A few things to try based on your requirement:

    --If you have a requirement about background processing within your web application, then as Alan mentioned – the recommended solution is to use Azure WebJobs/or Azure Function App.
    --For longer processing times, consider using the Durable Functions async pattern or defer the actual work and return an immediate response.

    --I understand you have mentioned about KeepAlive implementation already-
    --You could keep the connection active for a longer period is to use TCP Keep-alive. Packets are sent when no activity is detected on the connection. By keeping on-going network activity, the idle timeout value is never hit, and the connection is maintained for a long period. Try something like this:

    • First request starts the script and returns an http 202
    • Subsequent requests from client check the work, and eventually return 200 when it's done.

    Checkout these reference discussion threads. Once again I understand you have looked into approachs for reimplementing the solution to tackle timeout. Kindly checkout the above and let us know if you have any further questions.

    2 people found this answer helpful.
    0 comments No comments

  2. Alan Kinane 16,906 Reputation points MVP
    2022-04-25T13:27:16.393+00:00

    I'm not sure that this can be extended. There is a 4 minute limit on the Azure Load Balancer.

    There's a recommendation here to use WebJobs instead.

    https://learn.microsoft.com/en-us/troubleshoot/azure/general/web-apps-performance-faqs#why-does-my-request-time-out-after-230-seconds

    196193-image.png

    Another thread on this here:
    https://techcommunity.microsoft.com/t5/apps-on-azure/app-service-timeout-in-230-sec/m-p/1526934

    1 person found this answer helpful.
    0 comments No comments

  3. Igor Naumoski 1 Reputation point
    2022-12-23T12:14:37.303+00:00

    I have the same situation, but the connection is not idle. We are using SIgnalR which is actually working and sending messages but still we get the timeout. Even after the timeout the application crushes, but the SignalR is still sending messages. However the http request is also processing in same time so I guess this one is making the problem.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.