2

I meet a problems when deploy my code to Azure Funtions using App Service Plan. My function is long running (about 4 minutes, for business logic) and when I call it by Post man, it response 502.

The specified CGI application encountered an error and the server terminated the process.

In this time my function is still running, I monitor on the portal of Function Apps and it return a success response after 4 minutes, but I meet error and can not receive the response when call from client.

Response Message & Status Code Response Header

I read below link and see that may be the limitation is from Azure App Service Plan, but how to config ASP to solve this error ?

Some information: - Azure Functions V2. - App Service Plan S1 Standard, 2 instances.

The specified CGI application encountered an error and the server terminated the process

1 Answers1

1

I was having a similar issue, after debugging it turned out i had an unhandled exception inside a Parallel.Foreach Loop. The parallel loop did not have any try/catch within it, and as a result having an exception thrown bubbled up to the app domain killing and restarting the web app, with this same error showing: "The specified CGI application encountered an error and the server terminated the process." You should check all your asynchronous threads for error capturing

Gabriel
  • 595
  • 7
  • 10
  • I tried to implement try catch the library I used, but it's still not work, the request run below 120s it's okay but over 120s the error above happen. – fly_to_the_sky Mar 23 '18 at 05:00
  • And i don't use any async or await feature, no parallel for each loop as well, I implement loop but it's sequence – fly_to_the_sky Mar 23 '18 at 05:02
  • In case the library you are using is facing any unhandled exception within a thread it is creating this might happen as well and the try/catch you added won't help. Check for updates on the library or involve their support – Gabriel Mar 24 '18 at 08:08