简体   繁体   中英

ASP.Net request raises 502 Bad Gateway or TimeOut

I have a C# ASP.NET Webforms website running on IIS7. It is a report creation application that queries the SQL Server database, gets the data, parses it in to an Excel document.

The query itself doesn't take too long, but writing to the Excel takes a while when the query is very large (50,000 rows).

Now for the problem, when I run the report app, I get the report with in a few minutes but when some users run it, the report returns 502 Bad Gateway. This only happens for large reports.

I assume that it has to do with a timeout? Even though no matter which timeout command I change, the gateway error comes up with in two minutes.

I have the same error 502 on ASP.NET Core, while build large reports. My issue is not in out of memory. Logs show me that the process is not interrupted while i've got the error 502, and it continue builds reports til the end. The reason of the error is timeout from IIS. If i set "requestTimeout" like:

<aspNetCore requestTimeout="00:20:00" processPath=".\xxx.exe" arguments="" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout">
</aspNetCore>

in web.config, so for local URL (with localhost) - the error 502 will disappear and i'll get all reports, even huge, but for external URL (with domain names) timeout still the same - 120 sec, and 502 error. RequestTimeout in web.config and the next settings completely resolve my problem: In the Internet Information Services dialog box, expand local computer > Sites and right click Default Website and select Manage Web Site > Advance Settings. Expand Connection Limits, change the Time-out value to XXXX, and click OK.

The issue had to do with memory and we had to change the architecture. Since then, we have moved to dedicated report servers and split the reports into different parts (ie different time frames) and combined them again once each report is done. This can easily be achieved via Azure Queue and Blob Storage. The reports are also emailed instead of returned back in an HTTP call.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM