简体   繁体   English

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

[英]502 Error in Web API for large size of data

Technologies技术

I am using angular 2 and web API technologies in my application.我在我的应用程序中使用了 angular 2 和 Web API 技术。 I am calling web API service method from angular via $http call.我正在通过 $http 调用从 angular 调用 Web API 服务方法。

What I am doing我在做什么

Actually API method is reading data from data base and doing huge logic to transform the data for UI entity class (lot of codes and loops are there, so i won't post those here).实际上 API 方法是从数据库中读取数据并执行大量逻辑来转换 UI 实体类的数据(那里有很多代码和循环,所以我不会在这里发布)。

What is the problem & root cause问题和根本原因是什么

The problem is I am getting 502 Bad get way error when I am calling the API method.问题是我在调用 API 方法时收到 502 Bad get way 错误。

I found the problem because of it's a performance issue.我发现了这个问题,因为它是一个性能问题。 it's working fine for me when the data size is low.当数据量很小时,它对我来说很好用。 But if the data size is large, then I am getting this error.但是如果数据量很大,那么我就会收到这个错误。

Note : I have checked the data base query.注意:我已经检查了数据库查询。 and it's working fine and return the data very fast.它工作正常并且返回数据非常快。

Performance result details性能结果详情

I have used timer to check the response time of API method我已经使用计时器来检查 API 方法的响应时间

Result of response time as follow :响应时间结果如下:

  • if the data size is low : 00.00:898767 (hh:mm:ss)如果数据大小较低:00.00:898767 (hh:mm:ss)

  • if the data size is huge : 00:06:654389 (hh:mm:ss)如果数据量很大:00:06:654389 (hh:mm:ss)

What I understood:我的理解:

If the method response time is more than 2 mins, then only I am getting the bad get way error.如果方法响应时间超过 2 分钟,那么只有我遇到了错误的获取方式错误。 otherwise the method executed successfully without any error.否则方法成功执行,没有任何错误。

What I tried to fix this error:我试图修复这个错误:

I have tried to increase the executionTimeout=9000 in web config.我试图增加web config.executionTimeout=9000 web config. I also tried with different seconds in executionTimeout.我还尝试在executionTimeout.使用不同的秒数executionTimeout.

this is my full web config code这是我的完整网络配置代码

<?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?你能告诉我如何解决这个问题吗?

I solved this defect by adding requestTimeout="00:10:00" in <aspNetCore/> section我通过在<aspNetCore/>部分添加requestTimeout="00:10:00"解决了这个缺陷

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 处理Web API返回的大型JSON数据 - Dealing with large JSON data returned by Web API Web API大文件发布OutOfMemoryException错误 - Web API large File Post OutOfMemoryException error HTTP 502代理错误-响应标头的大小太大。 请与您的ISA服务器管理员联系。 (12216) - HTTP 502 Proxy Error - The size of the response header is too large. Contact your ISA server administrator. (12216) 为什么我的.NET Core Web API(在AWS Lambda上部署)返回502 Bad Gateway错误? - Why does my .NET Core Web API (deployed on AWS Lambda) return a 502 Bad Gateway error? 如何通过Web API快速导出大量数据 - How to export large amount of data fast via Web API 上传大文件 - Azure App Service 上的 502 bad gateway 错误 - Upload large file - 502 bad gateway error on Azure App Service 第二次Web API请求数据错误 - Web API Request Data error on second time 通过API导入大数据 - Importing large data by API 提取大量数据时,使用jQuery调用的WebMethod返回服务器错误。 数据大小是否有限制? - WebMethod called using jQuery returning server error when fetching large amounts of data. Is there a limitation on the data size? 在Web API 2中控制图像大小和视频大小 - Control image size and video size in Web API 2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM