Ramesh Rajendran
Ramesh Rajendran

Reputation: 38683

502 Error in Web API for large size of data

Technologies

I am using angular 2 and web API technologies in my application. I am calling web API service method from angular via $http call.

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).

What is the problem & root cause

The problem is I am getting 502 Bad get way error when I am calling the API method.

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

Result of response time as follow :

What I understood:

If the method response time is more than 2 mins, then only I am getting the bad get way error. 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. I also tried with different seconds in 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?

Upvotes: 6

Views: 9650

Answers (1)

Ramesh Rajendran
Ramesh Rajendran

Reputation: 38683

I solved this defect by adding requestTimeout="00:10:00" in <aspNetCore/> section

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

Upvotes: 4

Related Questions