ASP.Net请求引发502错误的网关或超时 [英] ASP.Net request raises 502 Bad Gateway or TimeOut

查看:453
本文介绍了ASP.Net请求引发502错误的网关或超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在IIS7上运行的C#ASP.NET Webforms网站.这是一个报表创建应用程序,可以查询SQL Server数据库,获取数据并将其解析为Excel文档.

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.

查询本身不会花费太长时间,但是当查询很大(50,000行)时,写入Excel会花费一些时间.

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

现在是问题所在,当我运行报表应用程序时,几分钟之内即可获取报表,但是当某些用户运行报表时,报表将返回502 Bad Gateway. 这仅适用于大型报告.

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.

推荐答案

在构建大型报表时,我在ASP.NET Core上遇到相同的错误502.我的问题不是内存不足.日志显示,在出现错误502时,该过程没有中断,并且它将继续生成报告直到结束.错误的原因是IIS超时.如果我将"requestTimeout"设置为:

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>

在web.config中,因此对于本地URL(使用localhost)-错误502将消失,并且我将获得所有报告,甚至是巨大的报告,但是对于外部URL(使用域名),超时仍然相同-120秒,和502错误. web.config中的RequestTimeout和下一个设置完全解决了我的问题:在Internet Information Services对话框中,展开本地计算机>网站,然后右键单击默认网站,然后选择管理网站>高级设置.展开连接限制",将超时"值更改为XXXX,然后单击确定".

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.

这篇关于ASP.Net请求引发502错误的网关或超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆