c# - 大数据量的 Web API 中的 502 错误

标签 c# asp.net angular asp.net-web-api web-config

技术
我在我的应用程序中使用了 angular 2 和 Web API 技术。我正在通过 $http 调用从 angular 调用 Web API 服务方法。
我在做什么
实际上API方法是从数据库中读取数据并做巨大的为 UI 实体类转换数据的逻辑(那里有很多代码和循环,所以我不会在这里发布它们)。
问题和根本原因是什么
问题是我在调用 API 方法时收到 502 Bad get way 错误。
我发现了这个问题,因为它是一个性能问题。当数据量很小时,它对我来说很好用。但是如果数据量很大,那么我就会收到这个错误。
注意:我已经检查了数据库查询。它工作正常并且返回数据非常快。
性能结果详情
我已经使用计时器来检查 API 方法的响应时间

Result of response time as follow :


  • 如果数据大小较低:00.00:898767 (hh:mm:ss)
  • 如果数据量很大:00:06:654389 (hh:mm:ss)

  • 我的理解:
    如果方法响应时间超过 2 分钟,那么只有我遇到了错误的获取方式错误。否则方法成功执行,没有任何错误。
    我试图修复这个错误:
    我试过增加executionTimeout=9000web config.我也在 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?

    最佳答案

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

    <aspNetCore processPath="%LAUNCHER_PATH%"  requestTimeout="00:10:00" 
    arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" 
    forwardWindowsAuthToken="true" />
    

    关于c# - 大数据量的 Web API 中的 502 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51894782/

    相关文章:

    c# - BinaryFormatter 对象图升级

    ASP.net 使用 OWIN 进行 Azure Active Directory 联合身份验证服务单点登录

    c# - 获取 IEnumerable 错误 : CS1061 does not contain C# ASP. NET MVC5

    angular - 如何在 rxjs6 中导入 ErrorObservable 或 _throw?扔进 rxjs

    c# - 代码使用错误的命名空间

    c# - 声称类似于 Windows 任务栏的桌面空间的 WPF 应用程序

    c# - 将 DLL 库引用添加到 VSX 中的项目

    c# - 我可以通过 WCF 服务创建自定义角色提供者吗?

    angular - 无法使用 angular-cli 创建 Angular 5 项目

    angular - 使用 F5 在 Angular 项目中进行 vscode TypeScript 调试。没有破裂或在错误的地方