简体   繁体   English

ASP.Net 请求引发 502 Bad Gateway 或 TimeOut

[英]ASP.Net request raises 502 Bad Gateway or TimeOut

I have a C# ASP.NET Webforms website running on IIS7.我有一个在 IIS7 上运行的 C# ASP.NET Webforms 网站。 It is a report creation application that queries the SQL Server database, gets the data, parses it in to an Excel document.它是一个报表创建应用程序,可查询 SQL Server 数据库、获取数据、将其解析为 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).查询本身不会花费太长时间,但是当查询非常大(50,000 行)时,写入 Excel 需要一段时间。

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.现在的问题是,当我运行报告应用程序时,我会在几分钟内得到报告,但是当一些用户运行它时,报告返回 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.我在 ASP.NET Core 上有相同的错误 502,同时生成大型报告。 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.日志显示,当我收到错误 502 时,该过程没有中断,并且它会继续构建报告直到结束。 The reason of the error is timeout from IIS.错误的原因是 IIS 超时。 If i set "requestTimeout" like:如果我将“requestTimeout”设置为:

<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.在 web.config 中,因此对于本地 URL(带有 localhost) - 错误 502 将消失,我会得到所有报告,甚至是巨大的,但是对于外部 URL(带有域名)超时仍然相同 - 120 秒和 502 错误. 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. web.config 中的 RequestTimeout 和下一个设置完全解决了我的问题:在 Internet 信息服务对话框中,展开本地计算机 > 站点并右键单击默认网站并选择管理网站 > 高级设置。 Expand Connection Limits, change the Time-out value to XXXX, and click OK.展开连接限制,将超时值更改为 XXXX,然后单击确定。

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.这可以通过 Azure 队列和 Blob 存储轻松实现。 The reports are also emailed instead of returned back in an HTTP call.报告也会通过电子邮件发送,而不是通过 HTTP 调用返回。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ASP.NET Core 2.0 ngrok 502 错误网关错误 - ASP.NET Core 2.0 ngrok 502 Bad Gateway Error 如何在ASP.NET MVC 5中调用SOAP Web服务时修复502 Bad Gateway错误? - How to fix 502 Bad Gateway error when calling SOAP webservice in ASP.NET MVC 5? 上传大文件时 502 Bad Gateway nginx 和 ASP.NET Core 3.1 - 502 Bad Gateway nginx and ASP.NET Core 3.1 when upload big file 从 Azure 中托管的 Asp.net Core MVC Web App 获取“响应状态代码并不表示成功:502(坏网关)” - Getting "Response status code does not indicate success: 502 (Bad Gateway)" from Asp.net Core MVC Web App hosted in Azure ASP.NET 5返回502.3 –错误的网关 - ASP.NET 5 returns 502.3 – Bad Gateway asp.net错误请求 - asp.net Bad Request 在容器网络中为 ASP .NET WebApp 设置 Nginx 时出现 502 错误网关 - 502 Bad Gateway while setting up Nginx for an ASP .NET WebApp in a Container Network 通过SSL通过HttpWebRequest发送请求时出现错误502(错误网关) - Error 502 (Bad Gateway) when sending a request with HttpWebRequest over SSL Azure /映像请求502(错误网关)错误 - 间歇性 - Azure / Image request 502 (Bad gateway) error - intermittent 从asp.net向influxDB发出POST请求期间出现错误请求 - Bad request during POST request to influxDB from asp.net
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM