Azure 4 minute web application timeout

My project is an ASP.NET MVC 4 project.

It works fine on localhost when I host it on Azure I get a timeout on ajax calls that take more than 4 minutes. I am sure that the problem is with azure because it does not matter what I do on the server. even just set Thread.sleep(300000) I get a timeout.

I read: https://azure.microsoft.com/en-us/blog/new-configurable-idle-timeout-for-azure-load-balancer/ This

It is common practice to maintain an active connection for a longer period to use TCP Keep-alive

and there is no other option for web applications. Therefore, I assume that I need help to maintain code in asp.net. I can’t figure it out myself. I tried to send a simple ajax call to the server every minute, and this does not help me, so I tried to use TcpKeepAlive as follows:

 public JsonResult MyLongOperation() { HttpWebRequest request =(HttpWebRequest)WebRequest.Create("mySite"); request.Proxy = null; request.ServicePoint.SetTcpKeepAlive(true, 30000, 5000); Thread.Sleep(300000);//5 min sleep return Json("ok",JsonRequestBehavior.AllowGet); } 

Doesn't work, I need help!

+5
source share
2 answers

Have you tried request.KeepAlive = true;

0
source

Source: https://habr.com/ru/post/1234908/


All Articles