azureazure-application-gateway

Microsoft Azure App Gateway Returning 499/504 Erorr


We have a dotnet api running on an Azure App Service that is routed through an Application Gateway. For one particular api call, we are seeing strange behavior occurring.

When the api is used as intended, with a frontend ui, the response the frontend receives is a 504 error after 4 minutes (which I believe is the time limit set in Azure for App Services). This also occurs if you call the api directly using something like Postman. Application Insights however, is reporting that the return status code for this particular operation is actually a 499 error code.

However, if you bypass the custom domain set for this api and call the App Service uri directly, this very same response with the same data returns after a little over 2-3 minutes (well below the app service max) successfully as we want without either a 499 or 504 error status code.

This has lead me to believe that the issue must be coming from the Application Gateway itself. However, in the backend settings for this particular application, the timeout is set to 600 seconds, so I am unsure where else this sort of limit is taking place. Is there another setting in the App Gateway I should be looking at that would cause this problem?


Solution

  • The issue is caused by a timeout mismatch between the client, Application Gateway, and the App Service,

    To resolve the issue,

    Refer this doc to know more about curl timeout options.

    curl -m 600 https://your-api-endpoint
    

    If possible, use Azure Front Door Instead of App Gateway, as it handles long-running requests better in some cases.