0

I am facing a problem with my ASP NET configuration which is hosted on the azure app service. When I call my ASP NET controller from the frontend page with an AJAX call, the controller is trying to process some external requests, DB calls, etc. There is a huge amount of logic that takes some time and it's up to 4-5 minutes or even more. So after 2 minutes or more, the status code of 504 gateway timeout is returned. That's normal because the time of operation on the controller exceeded the default asp net maximum call time. From the user's perspective, there is no problem with waiting 5 or even 10 minutes to complete the whole operation on the controller and return status code 200. I want the user to wait till it's completed but 504 occurs and the whole operation crashes. Is there any chance to change that default behavior and force the ASP NET controller to not return 504 but wait a few minutes or more till the operation is complete? I know, maybe I should use azure functions queue endpoint or something like this but it does not make any sense in that case due to the need to be synchronously called from the frontend with the result of the process presented for the user.

Hawos
  • 33
  • 6
  • Its better to not wait but put it on a query, and when its finish the user see the results - and not just wait for 10 minutes for something to finish. – Aristos Oct 23 '22 at 11:31
  • Rather than increasing the timeout, you need to optimize your performance and probably fix your architecture. Why is it taking so long? Have you profiled it? What takes the majority of the time? Can that be optimized? Are your database queries incorrectly written, are you looping over the wrong thing, are you missing indexes or primary keys on your tables? If all of that is good and it's still slow, then comes the architecture: long running processes should not execute in the context of a web application. Instead let your web app receive details about the request, and push that info to a queue – mason Oct 23 '22 at 13:31
  • ..such as Azure Service Bus. Then something (such as an Azure Function) can process the message from the queue and gather the data up and store it somewhere, and perhaps notify the UI that the data is ready, at which point the user can then go and retrieve this pre-packaged data. It will result in a much cleaner user experience and allow you to independently scale your background worker (Azure Functions in this case) from your web app, as they likely have different performance needs. Use the right tool and design for the job! – mason Oct 23 '22 at 13:32
  • Guys I know it's better to use azure funciton or something like this but can't. It has to be done with this way and it is not my requirement. I just want to know how to change that limit, could you help me please? – Hawos Oct 24 '22 at 06:42

0 Answers0