简体   繁体   English

Azure 网站错误 502

[英]Azure Website Error 502

I have an ASP.NET Webforms Application on Azure but i always get the following Error on some sites: 502 - Web server received an invalid response while acting as a gateway or proxy server.我在 Azure 上有一个 ASP.NET Webforms 应用程序,但在某些站点上总是出现以下错误: 502 - Web 服务器在充当网关或代理服务器时收到无效响应。

I already read a lot of topics regarding the 502 error on Azure but i still don't understand what the problem in my particular situation is.我已经阅读了很多关于 Azure 上 502 错误的主题,但我仍然不明白我的特定情况下的问题是什么。

The error occurs just on some site of the application.该错误仅发生在应用程序的某些站点上。 I can always reproduce the following pattern:我总是可以重现以下模式:

  • Open SITENAME.azurewebsites.net -> Error occurs打开 SITENAME.azurewebsites.net -> 发生错误
  • Open SITENAME.azurewebsites.net/Site1.aspx -> Error not occuring打开 SITENAME.azurewebsites.net/Site1.aspx -> 未发生错误
  • Open SITENAME.azurewebsites.net/Site2.aspx -> Error not occuring打开 SITENAME.azurewebsites.net/Site2.aspx -> 未发生错误
  • Refresh SITENAME.azurewebsites.net/Site2.aspx -> Error occurs and won't go away until i call Site1.aspx again刷新 SITENAME.azurewebsites.net/Site2.aspx -> 发生错误并且在我再次调用 Site1.aspx 之前不会消失

The only thing i found in the log is, that the application loads System.Windows.Forms.dll and there is an AccessViolationException.我在日志中发现的唯一一件事是,应用程序加载 System.Windows.Forms.dll 并且存在 AccessViolationException。 I have no idea why this dll is loaded at all because there is no Reference in any Project in Visual Studio to it but thats another story :).我完全不知道为什么要加载这个 dll,因为 Visual Studio 中的任何项目中都没有对它的引用,但那是另一回事了:)。

But what i don't understand is that the error 502 does not always occur on Site 502. Maybe someone can give me a hint what might be the problem or how i could find it...但我不明白的是,错误 502 并不总是发生在站点 502 上。也许有人可以给我一个提示,可能是什么问题或我如何找到它...

Thanks for your help!谢谢你的帮助!

EDIT: What i forgot to mention: In some threads regarding this error i read, that it occurs after 3 minutes or something like that.编辑:我忘记提及的内容:在我读到的有关此错误的一些线程中,它发生在 3 分钟或类似的事情之后。 In my case it is nearly alway about 25 seconds until the errormessage shows up.在我的情况下,在错误消息出现之前几乎总是大约 25 秒。

That points to an application issue.这指向一个应用程序问题。 The reason you are etting 502 is because the worker process is crashing and the front end is left with a request with no response and returning a 502 to say exactly that.你设置 502 的原因是因为工作进程崩溃了,前端留下一个没有响应的请求,并返回一个 502 来说明这一点。 Look for eventlog.xml under the LogFiles folder for your website.在您网站的 LogFiles 文件夹下查找eventlog.xml Alternatively you can try remote debugging from VS to your website .或者,您可以尝试从 VS 远程调试到您的网站

System.Windows.Forms.dll contains a lot of UI code that will most probably not work Azure websites sandbox. System.Windows.Forms.dll包含很多 UI 代码,这些代码很可能无法在 Azure 网站沙箱中运行。 The reason it's loaded is probably because you are using something from the assembly or using something that uses something from that assembly.加载它的原因可能是因为您正在使用程序集中的某些内容或使用该程序集中的某些内容。 It doesn't have to be listed in Visual Studio to be loaded since it's a part of the standard .NET Framework.它不必在 Visual Studio 中列出才能加载,因为它是标准 .NET Framework 的一部分。

I would suggest looking into remote debugging and figuring out at what point this is getting loaded and why.我建议研究远程调试并弄清楚这是在什么时候加载的以及为什么。

In my case, I got 502 errors because the site was restarted by the azure auto-heal system.就我而言,我收到 502 错误,因为该站点已被 azure 自动修复系统重新启动。 It turns out I made tests with that auto-heal system a few days ago, but since in the end I disabled it, I didn't think it could cause my 502 errors.事实证明,几天前我使用该自动修复系统进行了测试,但由于最后我禁用了它,我认为它不会导致我的 502 错误。

This is where I discovered that the azure interface to change auto-heal settings (mywebsite.scm.azurewebsites.net/Support -> mitigate) only affects the production slot.这是我发现更改自动修复设置的 azure 界面(mywebsite.scm.azurewebsites.net/Support ->缓解)仅影响生产槽的地方。 But when you swap your deployment slots, the settings get swapped.但是当您交换部署槽时,设置会被交换。 There is apparently no way to directly change the staging slot settings, you have to swap, change settings, and swap again.显然没有办法直接更改暂存槽设置,您必须交换、更改设置并再次交换。

So, I ended up having my staging slot with auto-heal enabled, and my production slot with auto-heal disabled (and of course at that time I thought it was disabled on both slots).所以,我最终让我的临时插槽启用了自动修复,而我的生产插槽禁用了自动修复(当然当时我认为它在两个插槽上都被禁用)。 Then I was "randomly" hitting 502 errors either on staging or production depending on how many times I swapped them.然后我在登台或生产中“随机”遇到 502 个错误,这取决于我交换它们的次数。 What's weird is that though the application seems to restart (or at least fails to respond to a few requests), I don't get the corresponding events in my log file, like if it wasn't running Application_Start after an app pool recycle triggered by the auto-heal system.奇怪的是,虽然应用程序似乎重新启动(或至少无法响应一些请求),但我没有在我的日志文件中获得相应的事件,就像在应用程序池回收触发后它没有运行 Application_Start通过自动修复系统。

Took me a whole day to find out what was happening, I hope this answer can help someone in the same situation.我花了一整天的时间才知道发生了什么,我希望这个答案可以帮助处于相同情况的人。

I got the error for a while after fiddling with connection strings, went away and came back in an hour, and the issue had disappeared and the site worked normally again.在摆弄连接字符串后,我得到了一段时间的错误,离开并在一个小时后回来,问题消失了,站点再次正常工作。 A highly technical answer for you.为您提供高度技术性的答案。

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

相关问题 将MVC 6网站部署到Azure会导致错误502 - Deploying MVC 6 website to Azure results in error 502 502在azure'网站'内请求付款服务 - 502 requesting payment service inside azure 'website' 将简单的Identity Server 3部署到Azure时出现HTTP错误502 - HTTP error 502 when deploying simple Identity Server 3 to Azure Azure /映像请求502(错误网关)错误 - 间歇性 - Azure / Image request 502 (Bad gateway) error - intermittent 如何修复 Azure Function 上的此 502 错误? - How do I fix this 502 Error on my Azure Function? 上传大文件 - Azure App Service 上的 502 bad gateway 错误 - Upload large file - 502 bad gateway error on Azure App Service 502 错误:使用 IronPDF 的 Azure 应用服务上的网关错误 - 502 Error: Bad Gateway on Azure App Service with IronPDF 错误(502)错误的网关:当尝试使用WebChat通道访问Azure上部署的聊天机器人时 - Error (502) Bad Gateway: When trying to access chatbot deployed on Azure using WebChat channel 来自Azure AppService的GET请求返回自身将返回502 Bad Gateway错误 - GET Request from an Azure AppService back to itself returns a 502 Bad Gateway error 将网站上传到 Azure 后 Azure 上的错误消息 - Error message on Azure after upload website onto it
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM