Azure Website Error 502 - c#

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.

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.

In my case, I got 502 errors because the site was restarted by the azure auto-heal system. 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.
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. 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. 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.
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.

Related

Azure website hanging; killing request and refreshes fixes issue

I have something very weird happening on my Azure website just today. I have not released any new code lately.
Approximately every 3rd to 5th page that I request on the site, it will sit there and hang, and eventually get an Error 524 (presented by CloudFlare). It tells me that my server or database may be overloaded. Checking Azure everything's running fine at less than 10% consumption.
The weird thing is, on the page requests that hang, if I kill the request (clicking the X where the refresh button normally is on Google Chrome), then retry the page, it returns everything immediately.
This morning when I first noticed, I thought it might have been Azure, so I checked the Azure status page, and sure enough, my region was having latency problems.
But, the problems, according to Azure, have apparently been resolved, yet I'm still receiving these same symptoms/errors.
Checking my error table just shows the db calls that are timing out while this is occurring, no patterns that I could recognize.
I've checked App Insights as well, checking the pages before and after and nothing is jumping out at me. I have another user over in the eastern United States and he said he hasn't noticed anything and all is working great.
I don't know what else to be checking here. This is consistently-inconsistent!
Here's the website to try:
www.wrestlestat.com
This is really frustrating because both Azure and CloudFlare status pages say everything is working normally. This is still happnening for me, anywhere from 3 to 5 pages one will hang...
EDIT/UPDATE - 2 days after incident started it has magically fixed itself. I have no idea of anything done, and I released NO code changes to attempt a fix. I'm baffled.

Operation is Not Supported - System.Reflection.Assembly.LoadFile()

Just installed our application on a client's server, and we are seeing an error that we have never seen before. This program runs on hundreds of computers and servers around the world, and apparently this one is different. Our client is fairly security conscious, so I'm guessing we need to have them unlock something, but no idea where to start. Google search of the issue only gives me a bunch of PowerShell references.
When calling System.Reflection.Assembly.LoadFile() to load in a DLL, we receive an "Operation is not supported" error.
This is a .NET 4.0 C# application.
Thanks
Went to each non-working DLL, properties, UNBLOCK. Restarted our service, and everything started working.

CS0103: The name 'xxxx' does not exist. This randomly occurs

I have researched this quite a bit and while I can find a number of articles on the general issue and the code, unfortunately none quite like what we have.
Environment: We have 2 web servers running Windows 2012 and IIS 8. All running .net 2-4.5
Web Server 1: This is our main server that runs our main websites and web applications
Web Server 2: This runs our client websites
Code: Both sets of code are uncompiled. Both the shared code and the client websites are .NET 4 sites.
Scenario
On Web1 we have a set of website code that is shared amongst a number of client websites. On Web2 the client site is set up in IIS and a sub directory of the App_code is a virtual directory pointing to a folder in the shared code on web1. We also have another virtual folder that points to the Web1 code as well. We have over 100 websites running in this fashion for over a couple of months.
Recently a couple of our clients have contacted us to say that they are receiving an error when browsing to parts of their website that are served by these virtual directories. The file that it references in the error message is in a modules folder in the virtual directory. it is a .cs file.
It only seems to be one website at a time and if we make a change that forces IIS to 'recompile' the site (meaning that we make a slight change to the web.config, save it and then change it back and save again), the error disappears and the web site starts working correctly. When we check other sites that are in the exact same setup as the one failing, we do not get any errors and they work correctly.
We are whits end as the issue seems to be completely random. This issue has only started occurring in the last week or at least this is the first we have seen of it.
We are at the point where we believe that it might be an IIS 8 issue and something that might be occurring when it is trying to recompile a client web site but due to the randomness and the 'easy fix' it is difficult to troubleshoot or even know where to go looking for the issue.
Any help would be much appreciated.
Thanks
Don
What is the error you're having? Based on what you said, the behavior is random and points on a C# file, not much can be said and only guesses could be make...

DevFC.exe (Development Fabric) for Windows Azure Crashes

Whenever I debug my application (ASP.NET Web Application converted to Web Role), I am able to get to the login page. I go ahead and sign in, debug through that and it seems to work fine, but as soon as it takes me to the landing page after login, DevFC.exe stops working with the error:
An unhandled exception ('System.Net.Sockets.SocketException') occurred in DevFC.exe [8072].
Now, I've searched for the issue and have seen something about DevFC.exe crashing due to VMWare Workstation that listens on the same port (12000) and HTC Sync that also listens on that port. I have neither of those applications on my machine, so I am lost here. Using TCPView (from Sysinternals), I find no other application using that port.
The one thing I do notice is that [System Process] goes crazy creating connections to localhost:12000 once DevFC.exe gets started.
Anyone have some insight on this?
This might sound ridiculous but restarting your machine might solve the issue. If that doesn't work, try your project on a different machine. If the project works then there is an issue with your primary machine try uninstalling then reinstalling the Azure SDK. If the devFabric still crashes on the secondary machine then it's something related to your project.
You might want to take a look at the logs created in the DevFC folder here: %localappdata%\dftemp\DevFCLogs (C:\Users\[user]\AppData\Local\dftmp\DevFCLogs). This will hopefully shed light on the actual error (which in my case, was a conflict on port 12001. Ran netstat -ab afterwards and found it was vmware-hostd.exe. This is a service included with VMWare Workstation 8. I know you said you don't have that, but you may have some other conflicting software).
See this thread as well for more detail.
http://social.msdn.microsoft.com/Forums/en-US/windowsazuredevelopment/thread/7e205afd-4b9a-4387-8e10-99e4b8f27788

Nod32 causing LocalHost (ASP.NET Development Server) "Connection Interrupted" Problem

I'm quoting myself on a previous question I asked to further explain:
"I'm trying to run a freshly created ASP.NET Website using C#, however when I do so it launches FireFox and attempts to connect to http://localhost:1295/WebSite1/Default.aspx (for example), but after about 10-15 seconds it displays a "Connection Interrupted - The connection to the server was reset while the page was loading." Error.
This issue is also present with older ASP.NET C# pages/Web Services I've built in the past, nothing is actually running off the ASP.NET Development server."
This is the problem that was occuring, that is before I noticed every time I ran the website, the notification for the ASP.NET Server-startup showed one port (1130 for example), and when the website failed to load; it turns out it was attempting to load the site on another port (In this case, 1128). It was suggested that an anti-virus program could have caused this kind of redirection; low and behold uninstalling Nod32 fixed the problem!
So my question is: Has anyone found a way to create an exception or remove this functionality from Nod32?
Within Nod32 enter the Advanced Setup options, and turn off protocol filtering.
It's a known problem with NOD32. Looks like it's IMON module (protocol filter) accidentally does some modifications of TCP packets that go through it.
The solution is to either turn it off, or use a different software.

Categories