7

We just launched a site that runs on ASP.NET Core 1.1, Windows 2008R2, IIS 7.5 with all the latest patches to 2008 and asp.net. The site runs fine, but goes down with no apparent pattern. All of a sudden it would start returning 502 response:

502 – Web server received an invalid response while acting as a gateway or proxy server

Restarting the site in IIS, or recycling site’s application pool brings the site up, but the problem reoccurs within a few hours. As workaround, we configured IIS to recycle app pool every 90 minutes, and that seemed to keep the site up all of the time. Any recommendations on how to troubleshoot this problem?

Thank you!

Ross
  • 2,123
  • 1
  • 18
  • 18

1 Answers1

2

IIS says with this 502 error that Kestrel (behind it) returned something "wrong". Enable (more) logging, and inspect logs before first 502 response. Some previous request "breaks" your app.

Dmitry
  • 16,110
  • 4
  • 61
  • 73
  • AspNetCore logging is enabled via stdoutLogEnabled in web.config There are no failed requests in the log. The last page requested before IIS starts returning 502 error is not consistent/different. – Ross Dec 06 '16 at 14:58
  • Find local port number (instead 5000) that IIS use to start you app (say, 12345). Open it inside server (http://localhost:12345) - does your app still works? – Dmitry Dec 06 '16 at 15:04
  • I assume you want me to do it when the site goes down with 502 error? That will be hard to do as this is a production site and recycling memory every hour keeps it going almost all the time. I tried your suggestion just now while the site is up and accessing http://localhost:24525 returned an empty page (no errors). Not sure why it’s not returning the home page… Is the blank page is that what you expect me to see when the site is down? – Ross Dec 06 '16 at 15:53
  • Any chance you are manually handling large file uploads or otherwise performing memory intensive operations, or have a component leaking memory? That could fit the pattern of random failures, and why recycling the app pool regularly keeps you up and running. See this question and linked article: http://stackoverflow.com/questions/36437282/dealing-with-large-file-uploads-on-asp-net-core-1-0 talking about request buffering and memory issues. – Dean Goodman Dec 08 '16 at 16:04
  • No file uploads of any size on this site. – Ross Dec 09 '16 at 04:41