502 Bad Gateway error page returned on XmlHttpRequests

I have a Mendix application using IIS as a front facing server. Intermittently users have been experiencing issues where triggering a microflow button results in an error. When checking this error in the browser console it looks like a 502 bad gateway error page HTML is being returned for the XmlHttpRequest to trigger the microflow. The user gets a Generic: Connection Error message popup and no errors are logged to the Mendix console (makes sense because nothing failed server side if there is a connection error as nothing was triggered) The Mendix console logs show that the sessions for the users were terminated and client access disabled for 300 seconds. Not sure it is related but it happens consistently around the time this issue is reported by the users. Any assistance would be greatly appreciated, I wish I had more information. Also are there any log nodes I can enable to get closer to the root cause without spamming log messages?
2 answers

The 502 error should only be shown if your application can't be reached, which if you didn't shut it down at that time it could be that your application is becoming unresponsive at certain moments.

This can have various causes. I'd recommend starting by reviewing your monitoring information. If you don't know the exact time the users started experiencing the issues the error message you were referring to is a good start.

Start by finding that time on the graph and scan down through all graphs and identify if there are spikes in any if the graphs within 1 hour before and after your chosen time. Depending type of graph that has the spike you should take different actions. For example if you only see a cpu spike in the app node there is likely X nr of microflows consuming all resources (X >= nr of CPUs), a spike on db node CPU indicates to many complicated queries, a spike in memory on app node indicates to many objects in memory.

To re-iterate, identifying all spikes at that problem time is most important to find the cause of your issue.

(Please note my examples on reading the report are overly simplified, and you need to look at the combination of graphs to draw a conclusion, a single graph can never indicate the root cause of your problem)


In my case, the 502 error was caused by the Application Request Routing feature of IIS. The Mendix application log didn't show any errors, but the IIS log did:

> 2017-03-02 09:11:09 POST /ws/<SomeWebService>/ X-ARR-CACHE-HIT=0&X-ARR-LOG-ID=e81c7817-3ee8-4521-90f4-e77bc59480cf 80 - <IP address> Mono+Web+Services+Client+Protocol+4.0.50524.0 - 502 3 12002 120019

The bold part led me to this page and this answer helped me to set the timeout, though I had to:

  • select the server
  • click the Application Request Routing feature
  • click Actions -> Server Proxy Settings ... (under Proxy)