Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Core deployed on IIS returns 502 Error for long running requests

I have an ASP.NET Core 2 web application which is hosted on IIS 10 on Windows Server 2012 without any load balancing and special configurations. For some MVC actions which takes too long we get a 502 HTTP error.

enter image description here

After seeing this error I was shocked, because I didn't have any configuration for a proxy server, etc. And then I remembered that the ASP.NET Core runs on Kestrel. So I came to this conclusion that here IIS plays the role of the proxy server and forwards the requests to the Kestrel. So I think this is somehow related to a timeout configuration, as the other parts of the application works very well. I have searched for similar questions on SO but no luck finding a solution.

like image 224
jacksparrow92 Avatar asked Feb 19 '18 15:02

jacksparrow92


1 Answers

I am getting same error when data is huge and take more time to execute web page, I have changed timeout value for .netcore in web.config

<?xml version="1.0" encoding="utf-8"?>
  <configuration>
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" 
           resourceType="Unspecified"/>
      </handlers>
      <aspNetCore requestTimeout="00:20:00"  processPath="%LAUNCHER_PATH%" 
          arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" 
         stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
    </system.webServer>
  </configuration>

I have add requestTimeout="00:20:00" in my existing web.config file and it works.

for reference go to this url

like image 102
Faraz Ahmed Avatar answered Sep 30 '22 05:09

Faraz Ahmed