Web 中的 502 错误 API 数据量较大
502 Error in Web API for large size of data
技术
我在我的应用程序中使用 angular 2 和网络 API 技术。我正在通过 $http 调用从 angular 调用网络 API 服务方法。
我在做什么
实际上 API 方法是从数据库中读取数据并执行 巨大的 逻辑来转换数据 UI实体class(那里有很多代码和循环,所以我不会post那些)。
问题及根本原因是什么
问题是当我调用 API 方法时出现 502 Bad get way 错误。
我发现了这个问题,因为它是一个性能问题。当数据量较小时,它对我来说工作正常。但是如果数据量很大,就会出现这个错误。
注意:我查了数据库查询。它运行良好,return 数据非常快。
性能结果详情
我已经使用计时器检查了API方法的响应时间
Result of response time as follow :
如果数据量较小:00.00:898767 (hh:mm:ss)
如果数据量很大:00:06:654389 (hh:mm:ss)
我的理解:
如果方法响应时间超过 2 分钟,那么只有我收到错误的获取方式错误。否则方法成功执行,没有任何错误。
我尝试修复此错误的方法:
我尝试在 web config.
中增加 executionTimeout=9000
我也在 executionTimeout.
中尝试了不同的秒数
这是我的完整网络配置代码
<?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>
but still i am unable to solve this problem. Could you please let me know how can I fix this issue?
我通过在 <aspNetCore/>
部分
中添加 requestTimeout="00:10:00"
解决了这个缺陷
<aspNetCore processPath="%LAUNCHER_PATH%" requestTimeout="00:10:00"
arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout"
forwardWindowsAuthToken="true" />
技术
我在我的应用程序中使用 angular 2 和网络 API 技术。我正在通过 $http 调用从 angular 调用网络 API 服务方法。
我在做什么
实际上 API 方法是从数据库中读取数据并执行 巨大的 逻辑来转换数据 UI实体class(那里有很多代码和循环,所以我不会post那些)。
问题及根本原因是什么
问题是当我调用 API 方法时出现 502 Bad get way 错误。
我发现了这个问题,因为它是一个性能问题。当数据量较小时,它对我来说工作正常。但是如果数据量很大,就会出现这个错误。
注意:我查了数据库查询。它运行良好,return 数据非常快。
性能结果详情
我已经使用计时器检查了API方法的响应时间
Result of response time as follow :
如果数据量较小:00.00:898767 (hh:mm:ss)
如果数据量很大:00:06:654389 (hh:mm:ss)
我的理解:
如果方法响应时间超过 2 分钟,那么只有我收到错误的获取方式错误。否则方法成功执行,没有任何错误。
我尝试修复此错误的方法:
我尝试在 web config.
中增加 executionTimeout=9000
我也在 executionTimeout.
这是我的完整网络配置代码
<?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>
but still i am unable to solve this problem. Could you please let me know how can I fix this issue?
我通过在 <aspNetCore/>
部分
requestTimeout="00:10:00"
解决了这个缺陷
<aspNetCore processPath="%LAUNCHER_PATH%" requestTimeout="00:10:00"
arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout"
forwardWindowsAuthToken="true" />