My project is an ASP.NET MVC 4 project.
While in localhost it works fine when I host it in Azure I get a timeout in ajax calls that take more than 4 minutes. I am sure that the problem is with azure because it doesn't matter what I'm doing in the server. even just set Thread.sleep(300000)
I get a timeout.
I read in: https://azure.microsoft.com/en-us/blog/new-configurable-idle-timeout-for-azure-load-balancer/ That
a common practice to keep the connection active for a longer period is to use TCP Keep-alive
and there is no other option for web apps. So I guess that what I need is help to keep alive code in asp.net. I can't figure this out by myself. tried to send every one minute simple ajax call to the server and this doesn't help me so I tried to use TcpKeepAlive like this:
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);
}
Didn't work,i need help please!!
Have you tried request.KeepAlive=true; ?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.