Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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.

The error occurs just on some site of the application. I can always reproduce the following pattern:

  • Open SITENAME.azurewebsites.net -> Error occurs
  • Open SITENAME.azurewebsites.net/Site1.aspx -> Error not occuring
  • Open SITENAME.azurewebsites.net/Site2.aspx -> Error not occuring
  • Refresh SITENAME.azurewebsites.net/Site2.aspx -> Error occurs and won't go away until i call Site1.aspx again

The only thing i found in the log is, that the application loads System.Windows.Forms.dll and there is an 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 :).

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

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. In my case it is nearly alway about 25 seconds until the errormessage shows up.

like image 254
metabolic Avatar asked Sep 06 '14 14:09

metabolic


People also ask

What does error 502 mean on a website?

The HyperText Transfer Protocol (HTTP) 502 Bad Gateway server error response code indicates that the server, while acting as a gateway or proxy, received an invalid response from the upstream server.

What is the cause of error 502?

The HTTP 502 - bad gateway error occurs when either: The timeout of the proxy was reached prior to the request completion. If the connection proxy > server drops. When the response from the server is invalid.

Is a 502 Bad gateway my fault?

There is a good chance that if you have run into this error message while browsing, you're not at fault. Typically, an Error 502 bad gateway indicates that there is an issue with the website's server, rather than anything on your end.


1 Answers

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. Look for eventlog.xml under the LogFiles folder for your website. Alternatively you can try remote debugging from VS to your website.

System.Windows.Forms.dll contains a lot of UI code that will most probably not work Azure websites sandbox. 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.

I would suggest looking into remote debugging and figuring out at what point this is getting loaded and why.

like image 124
ahmelsayed Avatar answered Sep 22 '22 14:09

ahmelsayed