Azure ASP net WebApp The request timed out

0 votes

I have deployed an ASP .net MVC web app to Azure App service.

I do a GET request from my site to some controller method which gets data from DB(DbContext). Sometimes the process of getting data from DB may take more than 4 minutes. That means that my request has no action more than 4 minutes. After that Azure kills the connection - I get message:

500 - The request timed out.

The web server failed to respond within the specified time.

This is a method example:

 [HttpGet]
    public async Task<JsonResult> LongGet(string testString)
    {            
       var task = Task.Delay(360000);
        await task;            
        return Json("Woke", JsonRequestBehavior.AllowGet);
    }

I have seen a lot of questions like this, but I got no answer:

Not working 1 Cant give other link - reputation is too low.

I have read this article - its about Azure Load Balancer which is not available for webapps, but its written that common way of handling my problem in Azure webapp is using TCP Keep-alive. So I changed my method:

[HttpGet]
    public async Task<JsonResult> LongPost(string testString)
    {
        ServicePointManager.SetTcpKeepAlive(true, 1000, 5000);
        ServicePointManager.MaxServicePointIdleTime = 400000;
        ServicePointManager.FindServicePoint(Request.Url).MaxIdleTime = 4000000;
       var task = Task.Delay(360000);
        await task;            
        return Json("Woke", JsonRequestBehavior.AllowGet);
    }

But still get same error. I am using simple GET request like

GET /Home/LongPost?testString="abc" HTTP/1.1
Host: longgetrequest.azurewebsites.net
Cache-Control: no-cache
Postman-Token: bde0d996-8cf3-2b3f-20cd-d704016b29c6

So I am looking for the answer what am I doing wrong and how to increase request timeout time in Azure Web app. Any help is appreciated.

Azure setting on portal:

Web sockets - On

Always On - On

App settings:

SCM_COMMAND_IDLE_TIMEOUT = 3600

WEBSITE_NODE_DEFAULT_VERSION = 4.2.3

Sep 24, 2018 in Azure by cloudie_crank
• 1,610 points
9,837 views

1 answer to this question.

0 votes

"230 seconds". That's it. That's the in-flight request timeout in Azure App Service. It's hardcoded in the platform so TCP keep-alives or not you're still bound by it.

Source -- see David Ebbo's answer here:
https://social.msdn.microsoft.com/Forums/en-US/17305ddc-07b2-436c-881b-286d1744c98f/503-errors-with-large-pdf-file?forum=windowsazurewebsitespreview

There is a 230 second (i.e. a little less than 4 mins) timeout for requests that are not sending any data back. After that, the client gets the 500 you saw, even though in reality the request is allowed to continue server side.

Without knowing more about your application it's difficult to suggest a different approach. However what's clear is that you do need a different approach --

Maybe return a 202 Accepted instead with a Location header to poll for the result later?

Hope this helps!!

If you need to know more about Azure, then you should join Microsoft Azure certification course today.

Thank you!!

answered Sep 24, 2018 by null_void
• 3,220 points

Related Questions In Azure

0 votes
2 answers

Which should i use for ASP.NET MVC Development: Windows Azure or Amazon EC2?

Both the cloud platforms have slightly varied ...READ MORE

answered Mar 7, 2019 in Azure by Prerna
• 1,960 points

reshown Mar 7, 2019 by Vardhan 1,178 views
0 votes
1 answer
0 votes
2 answers

How can I download a .vhd image to my local machine from azure and upload the same to a different azure account?

From the Windows Azure Portal you can ...READ MORE

answered Aug 20, 2018 in Azure by Priyaj
• 58,020 points
14,017 views
0 votes
2 answers

How can I view the deployed files in Azure?

In Visual Studio, in the window "Server ...READ MORE

answered Aug 21, 2018 in Azure by Priyaj
• 58,020 points
4,980 views
0 votes
1 answer

Are Docker and Azure Service Fabric both the same?

It's confusing since Docker (the company) is ...READ MORE

answered Jun 1, 2018 in Azure by null_void
• 3,220 points
2,770 views
+1 vote
10 answers

How can the NuGet packages be used in Azure Functions?

Yes! Although the Azure Functions portal does ...READ MORE

answered Jun 8, 2018 in Azure by club_seesharp
• 3,450 points
16,950 views
0 votes
1 answer

How to determine the number of messages in an Azure Services Bus Queue?

You will get error when you try ...READ MORE

answered Jun 12, 2018 in Azure by null_void
• 3,220 points
4,643 views
0 votes
1 answer

How can we rewrite an URL in Azure Webapp?

You need to create a web.config file ...READ MORE

answered Jun 14, 2018 in Azure by null_void
• 3,220 points
8,753 views
0 votes
1 answer

Is there a logical difference between WebApp and API app in Azure?

Basically there was only minute differences between ...READ MORE

answered Apr 27, 2018 in Azure by null_void
• 3,220 points
1,222 views
0 votes
2 answers

In Azure powershell Select-AzureSubscription command fetching error: the subscription name doesn't exist

The problem you're having is that the ...READ MORE

answered Aug 16, 2018 in Azure by Priyaj
• 58,020 points
7,677 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP