1

I have a website published on Microsoft Azure and lately I'm receiving the following error: "The specified CGI application encountered an error and the server terminated the process."

My application is Java app and using "Newest Tomcat 7.0". I tried some fixes, but it didn't work (The specified CGI application encountered an error and the server terminated the process). My web.config didn't even have this property.

From my logs I notice the Java application is not logging any error, but it simply goes down after some time. It works normally when i restart the server, but after one or two days, I start receiving this error.

I was having this problem before, but the error just appeared after one or two months, now lately, it is showing almost daily. And I didn't make any change on my files or server.

Any idea how to solve it?

Community
  • 1
  • 1

3 Answers3

3

Azure Websites have a feature called Auto-Healing. This is only available in standard mode, not in the free or basic mode.

You can configure the server to restart on a periodic basis. This won't fix the underlying root cause but it may be enough to keep your app running. Check out this github gist for how to confiure it in the web.config file

https://gist.github.com/SyntaxC4/0d7185b30acf477c2033#file-web-autoheal-config

Auto-Healing is described here in the azure website cheatsheet

http://microsoftazurewebsitescheatsheet.info/

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <monitoring>
      <triggers>
        <!-- Scenario #1: Recycling based on Request Count -->
        <requests count="1000" timeInterval="00:10:00"/>
        <!-- Scenario #2: Recycling based on slow requests -->
        <slowRequests timeTaken="00:00:45" count="20" timeInterval="00:02:00" />
        <!-- Scenario #3: Logging an event (or recycling) based on HTTP status code(s) -->
        <statusCode>
          <add statusCode="500" subStatusCode="100" win32StatusCode="0" count="10" timeInterval="00:00:30"/>
        </statusCode>
        <!-- Scenario #4: Taking custom actions (or recycling/logging) based on memory limit -->
        <memory privateBytesInKB="800000"/>
      </triggers>
      <!-- Scenario #1 & #2 Action -->
      <actions value="Recycle"/>
      <!-- Scenario #3 Action -->
      <actions value="LogEvent"/>
      <!-- Scenario #4 Action  -->
      <actions value="CustomAction">
        <customAction exe="d:\home\procdump.exe" parameters="-accepteula w3wp d:\home\w3wp_PID_%1%_" />
      </actions>
    </monitoring>
  </system.webServer>
</configuration>

AIDAN CASEY
  • 319
  • 2
  • 11
  • Hi, I m not sure to understand how the first 2 rules triggered the first action only? Is it possible to execute all the actions for only one trigger? I read that is possible to send email in an action, but I didnt find the way to do it, do you know how? – Cedric Arnould Jan 31 '19 at 21:30
1

Per my experience, I think you can try to check the logs like catalina.YYYY-MM-DD.log & site.YYYY-MM-DD.log in the path D:\home\LogFiles\ of Kudu Console https://<your webapp name>.scm.azurewebsites.net/DebugConsole to be sure what the reason is, such as Out of Memory or others.

Could you supply the error information in the logging files for analysing the issue?

I also searched some cases below that can cause the error.

  1. The memory usage over the limit of Azure WebApp Tier like Free Tier 1GB RAM. Then, you can try to upgrade a higher tier like Basic or Standard tier.

  2. For the exception Out of Memory, you can try to set appropriate values for Xms and Xmx in the JAVA_OPTS in web.config (httpPlatform section) -- For httpPlatform configuration, please refer to http://azure.microsoft.com/en-us/documentation/articles/web-sites-java-custom-upload/. Meanwhile, please debug your code whether the exception was caused by the unsuitable code logic.

Hope it helps. Best Regards.

Peter Pan
  • 23,476
  • 4
  • 25
  • 43
  • Doesn't seem to be this problem. I had looked before on this files, but i didn't find any error or anything that seems to be causing this problem. And i'm not on the free tier anymore. I will keep looking for the possible mistake. Thank you – Flavio H. Freitas Feb 02 '16 at 22:37
1

We have the similar problem with Web App and Tomcat in it. Sometimes Tomcat takes ~20-30 minutes to wake up (after an application was started, restarted or redeployed).

After reading this thread, we reviewed our configuration and found, that "Always On" property in Application Settings is in "Off" state, which means the Azure may unload an application if it's idle.

Frankly speaking, I'm not ready to say yet if setting this property to "On" will solve our problem. We've just changed this setting, and I need few days (week?) to say if the problem disappeared.

What I can suggest:

  1. Check if your app will wake up after some time (as I said, in our case, it's more than 20 minutes).
  2. If your answer to the previous question is yes, try to play with Always On property.

I hope, it gives you some clues

UPDATE 16-Oct-2017 "Always on" property works fine for us during few months. I re-read the initial question, and it looks like, that author had the same issue.

Ihor Kliushnikov
  • 388
  • 1
  • 5
  • 10
  • Excuse me, I can't agree that it's not an answer or it's a different question. The author may have a problem with Web Application, that can be unloaded by Azure in case of idle. From the other hand, Tomcat may require a lot of time to wake up, after provisioning. Therefore, if his application was not in use for some time, Azure unloaded it and any requests during nearest 10-20-30 minutes will be with 500th response. Maybe I need to rewrite the answer if it's not clear from it – Ihor Kliushnikov Aug 25 '17 at 11:54