加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – Azure ASP .net WebApp请求超时

发布时间:2020-12-15 04:35:37 所属栏目:百科 来源:网络整理
导读:我已经为Azure App服务部署了一个ASP .net MVC Web应用程序. 我从我的网站做一个GET请求到一些从DB(DbContext)获取数据的控制器方法.有时从DB获取数据的过程可能需要超过4分钟.这意味着我的请求超过4分钟没有动作.之后,Azure杀死了连接 – 我收到消息: 500
我已经为Azure App服务部署了一个ASP .net MVC Web应用程序.

我从我的网站做一个GET请求到一些从DB(DbContext)获取数据的控制器方法.有时从DB获取数据的过程可能需要超过4分钟.这意味着我的请求超过4分钟没有动作.之后,Azure杀死了连接 – 我收到消息:

500 – The request timed out.

The web server failed
to respond within the specified time.

这是一个方法示例:

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

我看到很多这样的问题,但我没有回答:

Not working 1
不能给其他链接 – 声誉太低.

我已经阅读了这个article – 它关于Azure Load Balancer,它不适用于webapps,但是它编写的在Azure webapp中处理我的问题的常见方法是使用TCP Keep-alive.所以我改变了我的方法:

[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);
    }

但仍然会收到相同的错误.
我正在使用简单的GET请求

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

所以我正在寻找答案我做错了什么以及如何在Azure Web应用程序中增加请求超时时间.任何帮助是赞赏.

门户上的Azure设置:

网络套接字 – 开

始终开启

应用设置:

SCM_COMMAND_IDLE_TIMEOUT = 3600

WEBSITE_NODE_DEFAULT_VERSION = 4.2.3

解决方法

230秒.而已.这是Azure App Service中的飞行中请求超时.它在平台上硬编码,所以TCP保持活着还是不受限制.

来源 – 请见David Ebbo的答案:
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.

不知道更多的应用程序,很难建议一种不同的方法.然而,很清楚的是,你需要一种不同的方法 –

也许返回一个202接受替换与一个位置标题来轮询结果以后?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读