ASP.Net request raises 502 Bad Gateway or TimeOut

北慕城南 提交于 2019-12-24 13:24:37

问题


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.


回答1:


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 (i.e 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.




回答2:


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.



来源:https://stackoverflow.com/questions/18021607/asp-net-request-raises-502-bad-gateway-or-timeout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!