我在应用程序中使用angular 2和Web API技术。我正在通过$ http调用从角度调用Web API服务方法。
实际上API方法是从数据库读取数据并执行huge逻辑以转换UI实体类的数据(有大量的代码和循环,因此在这里不再赘述)。
问题是我在调用API方法时遇到502 Bad get way错误。
我发现了问题,因为它是性能问题。数据量较小时,对我来说工作正常。但是,如果数据量很大,则会出现此错误。
注意:我已经检查了数据库查询。并且工作正常,并非常快速地返回数据。
我已经使用计时器检查API方法的响应时间
响应时间的结果如下:
如果数据大小较小:00.00:898767(hh:mm:ss)
如果数据量巨大:00:06:654389(hh:mm:ss)
如果方法响应时间超过2分钟,则只有我遇到错误的获取方法错误。否则,该方法将成功执行且没有任何错误。
我已经尝试增加executionTimeout=9000
中的web config.
,我也尝试过使用executionTimeout.
中的不同秒数
这是我的完整Web配置代码
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--
Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
-->
<system.web>
<authentication mode="Windows"></authentication>
<authorization>
<deny users="?" />
</authorization>
<httpRuntime executionTimeout = "9000" />
</system.web>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="true" />
</system.webServer>
</configuration>
但是我仍然无法解决这个问题。您能告诉我如何解决此问题吗?
我通过在requestTimeout="00:10:00"
部分中添加<aspNetCore/>
解决了该缺陷
<aspNetCore processPath="%LAUNCHER_PATH%" requestTimeout="00:10:00"
arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout"
forwardWindowsAuthToken="true" />