Azure 4 min timeout in web app

怎甘沉沦 提交于 2019-12-06 03:06:05

问题


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!!


回答1:


Had this problem too, found this, worked for me: https://azure.microsoft.com/en-us/blog/new-configurable-idle-timeout-for-azure-load-balancer/




回答2:


Have you tried request.KeepAlive=true; ?



来源:https://stackoverflow.com/questions/33449600/azure-4-min-timeout-in-web-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!