更新托管在 Azure 上的 .net 框架 MVC Web 应用的请求超时



我有一个托管在Azure上的MVC .NET Framework(4.5(Web应用程序,该应用程序使用ARR来实现外部API的反向代理。

似乎无论我尝试什么,一个长时间运行的请求都会在正好 502 分钟后返回 2 并带有消息:

The specified CGI application encountered an error and the server terminated the process.

我在 web.config 中有这个设置

<system.web>
<httpRuntime maxRequestLength="2097151" executionTimeout="3600" />
<compilation debug="false" targetFramework="4.5.2">
</system.web>

并在 Azure 上的站点根目录中进行此转换:

<?xml version="1.0"?>
<configuration  xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.applicationHost>
<webLimits xdt:Transform="SetAttributes(connectionTimeout)" 
connectionTimeout="00:05:00" />
</system.applicationHost>
</configuration>

我已经验证了应用程序主机.config在服务器上设置了webLimit连接超时,并重新启动了Web应用程序。但是,2 分钟后我仍然得到 502。我也可以直接命中端点而不会在 2 分钟后超时,但通过反向代理,它每次都会在 2 分钟停止。

我可能会缺少什么超时设置?

从 web.config 配置在 Azure 应用服务中不起作用:

<system.web>
<httpRuntime maxRequestLength="2097151" executionTimeout="3600" />
<compilation debug="false" targetFramework="4.5.2">
</system.web>

因为应用服务的默认超时为 240 秒。

在我看来,您应该对您的请求的子状态代码进行故障排除。此请求中的状态代码为 502,请查找子状态代码并对此进行进一步故障排除。

查看该问题,应用程序似乎需要一些时间来响应,可以使用Diagnostic and solve problem边栏选项卡从 Azure 门户本身冒泡并排查实际原因。

在 诊断并解决问题 中,查找Availability and performance部分并检查 5** 错误。

希望对您有所帮助。

最新更新