简体   繁体   English

Azure应用程序中的4分钟超时

[英]Azure 4 min timeout in web app

My project is an ASP.NET MVC 4 project. 我的项目是一个ASP.NET MVC 4项目。

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. 在localhost中,当我在Azure中托管它时工作正常我在ajax调用中超时需要超过4分钟。 I am sure that the problem is with azure because it doesn't matter what I'm doing in the server. 我确信问题出在azure上,因为我在服务器上做的并不重要。 even just set Thread.sleep(300000) I get a timeout. 即使只是设置Thread.sleep(300000)我也会超时。

I read in: https://azure.microsoft.com/en-us/blog/new-configurable-idle-timeout-for-azure-load-balancer/ That 我读到了: https//azure.microsoft.com/en-us/blog/new-configurable-idle-timeout-for-azure-load-balancer/

a common practice to keep the connection active for a longer period is to use TCP Keep-alive 保持连接活动较长时间的常见做法是使用TCP Keep-alive

and there is no other option for web apps. 并且没有其他Web应用程序选项。 So I guess that what I need is help to keep alive code in asp.net. 所以我想我需要的是帮助保持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: 试图将每一分钟简单的ajax调用发送到服务器,这对我没有帮助,所以我试着像这样使用TcpKeepAlive:

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; 你试过request.KeepAlive = true; ?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM