ASP.NET Core randomly restarts under IIS

12.8k Views Asked by At

We found a problem, ASP.NET Core application on some servers randomly restarts every day at random times.

  • Windows Server 2012 R2 Standard, IIS 8.5.9600.16384
  • Hosting bundle Microsoft.NETCore.App 2.1.4, Microsoft.AspNetCore.App 2.1.4
  • Out of process hosting model
  • Application pool recycling is disabled

In Event Viewer In Application Section

Application 'MACHINE/WEBROOT/APPHOST/APPLICATIONNAME' started process 'xxx' successfully and is listening on port 'xxx'. (Event ID 1001)

Sent shutdown HTTP message to process '6860' and received http status '202'. (Event ID 1006)

App_offline file 'app_offline.htm' was detected (Event ID 1012)

And in System Section at same time

The TCP/IP NetBIOS Helper service entered the running state. (Event ID 7036)

The TCP/IP NetBIOS Helper service entered the stopped state. (Event ID 7036)

The TCP/IP NetBIOS Helper service was successfully sent a stop control. The reason specified was: 0x40030011 [Operating System: Network Connectivity (Planned)] Comment: None (Event ID 7042)

All events happen in 2-3 seconds

3

There are 3 best solutions below

1
Daniil Sokolyuk On

Very strange behavior IIS and AspNetCoreModule when our application node have problems with DHCP when lease time has expired and LAN adapter refreshes DHCP leases.

At this point, the aspnet module starts to see the app_offline.htm file (we have no idea why this is happening) and then immediately restarts the application.

And only servers with this problem, DHCP was turned on. We specified a static IP address in the adapter settings to solve this problem.

1
No Refunds No Returns On

It sounds like you have periodicRestart configured on IIS. https://learn.microsoft.com/en-us/iis/configuration/system.applicationhost/applicationpools/add/recycling/periodicrestart/ I think the default interval is 29 hours. Disable this setting.

0
vernou On

I had a similar problem, where IIS stop the application pool randomly with the event log :

Sent shutdown HTTP message to process with Id '11076' and received http status '202'.

follow by

Application '/LM/W3SVC/82/ROOT/<MyApp>' with physical root 'Z:\wwwroot\<MySite>\<MyApp>\' shut down process with Id '11076' listening on port '42901'

IIS has a IDLE functionality, that stop the application pool when it is idle (no request during a period).

By default, the period is 20 minutes. I see the application pool start on the first request and it is stopped 20 minutes after.


To disable the IDLE, you can specify a interval time to 0 (corresponding to infinity) in the default pool application settings :

enter image description here