我有一个 ASP.NET Core 2.0 API,正在部署到 Azure 应用服务。这一直工作得很好,直到最近我不得不处理一个需要超过 2 分钟才能完成的请求,并且我得到了 502 Bad Gateway 说明
"The specified CGI application encountered an error and the server terminated the process".
当我在这个过程中达到 2 分钟时,这种情况就会持续发生。
我的诊断日志文件说
018-05-25 02:07:01.462 +00:00 [Error] Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware: An unhandled exception has occurred while executing the request
System.Threading.Tasks.TaskCanceledException: A task was canceled.
我正在假设这是一个超时问题,因为它始终处于 2 分钟标记,并且我知道该请求需要 2 分钟以上才能完成。因此,我正在研究如何增加超时,并在 SO 上找到了一些帖子,其中讨论了使用 applicationHost.xdt 文件,将其放置在站点的 Site 文件夹的根目录中。我正在使用这个 XML;
<?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>
当我使用 Kudu 调试控制台将其上传到我用来测试 API 的部署槽的站点文件夹的根目录,然后查看转换文件时,我看到以下内容:
2018-05-24T19:34:19 Start 'site' site extension transform
2018-05-24T19:34:19 StartSection Executing SetAttributes (transform line 4, 16)
2018-05-24T19:34:19 on /configuration/system.applicationHost/webLimits
2018-05-24T19:34:19 Applying to 'webLimits' element (no source line info)
2018-05-24T19:34:19 Set 'connectionTimeout' attribute
2018-05-24T19:34:19 Set 1 attributes
2018-05-24T19:34:19 EndSection Done executing SetAttributes
2018-05-24T19:34:19 Successful 'D:\home\site\applicationHost.xdt' site extension transform
在我看来,它成功地应用了 XDT 变换。
但是,即使在重新启动基础应用服务和相关部署槽之后也是如此。我仍然收到错误。
那么,我是否使用了错误的超时设置?
当我查看插槽站点/wwwroot 文件夹中的 web.config 文件时,它仅包含此...
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\Mypp.dll"
stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
我希望看到有关我应用的 XDT 文件中的连接超时的信息。那么,也许这不是正确的 web.config 文件?
我不是 Azure 专家,在这一点上,我觉得我在浪费时间,所以我想检查一下是否有人有任何建议。