[Web API中的502大量数据错误

问题描述 投票:2回答:1

技术

我在应用程序中使用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>

但是我仍然无法解决这个问题。您能告诉我如何解决此问题吗?

c# asp.net angular asp.net-web-api web-config
1个回答
1
投票

我通过在requestTimeout="00:10:00"部分中添加<aspNetCore/>解决了该缺陷

<aspNetCore processPath="%LAUNCHER_PATH%"  requestTimeout="00:10:00" 
arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" 
forwardWindowsAuthToken="true" />
© www.soinside.com 2019 - 2024. All rights reserved.