Open fabiano opened 5 years ago
I did a test here and dropped an app_offline.htm file in the application's folder. After some seconds the w3wp.exe process crashed.
Then I removed the attribute hostingModel="InProcess"
from my web.config file and repeated the test. This time the w3wp.exe process didn't crash.
@pakrym @jkotalik Could you guys take a quick look?
I get this exception when updating Microsoft.AspNetCore.SignalR from 1.0.4 to 1.1.0:
System.ObjectDisposedException: Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it has already been disposed.
at Autofac.Core.Lifetime.LifetimeScope.CheckNotDisposed()
at Autofac.Core.Lifetime.LifetimeScope.BeginLifetimeScope(Object tag)
at Autofac.Extensions.DependencyInjection.AutofacServiceScopeFactory.CreateScope() in C:\projects\autofac-extensions-dependencyinjection\src\Autofac.Extensions.DependencyInjection\AutofacServiceScopeFactory.cs:line 62
at Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher`1.OnDisconnectedAsync(HubConnectionContext connection, Exception exception)
at Microsoft.AspNetCore.SignalR.HubConnectionHandler`1.HubOnDisconnectedAsync(HubConnectionContext connection, Exception exception)
at Microsoft.AspNetCore.SignalR.HubConnectionHandler`1.RunHubAsync(HubConnectionContext connection)
at Microsoft.AspNetCore.SignalR.HubConnectionHandler`1.OnConnectedAsync(ConnectionContext connection)
at Microsoft.AspNetCore.SignalR.HubConnectionHandler`1.OnConnectedAsync(ConnectionContext connection)
at Microsoft.AspNetCore.Http.Connections.Internal.HttpConnectionDispatcher.ExecuteApplication(ConnectionDelegate connectionDelegate, HttpConnectionContext connection)
at Microsoft.AspNetCore.Http.Connections.Internal.HttpConnectionContext.WaitOnTasks(Task applicationTask, Task transportTask, Boolean closeGracefully)
at Microsoft.AspNetCore.Http.Connections.Internal.HttpConnectionContext.DisposeAsync(Boolean closeGracefully)
at Microsoft.AspNetCore.Http.Connections.Internal.HttpConnectionManager.DisposeAndRemoveAsync(HttpConnectionContext connection, Boolean closeGracefully)
at Microsoft.AspNetCore.Http.Connections.Internal.HttpConnectionManager.DisposeAndRemoveAsync(HttpConnectionContext connection, Boolean closeGracefully)
Triage: This looks like an issue with SignalR or app throwing an exception on a background thread on shutdown. @BrennanConroy can you take another look?
(w3wp crashing is a red herring here.)
@fabiano Can you share your eventlogs when running with out-of-proc. You should be looking for a dotnet.exe crash in that case.
@muratg The application is not crashing when running with out-of-process. Checked the logs and there is only the entries from IIS AspNetCore Module V2 shutting down the application:
Log Name: Application
Source: IIS AspNetCore Module V2
Date: 2/27/2019 1:56:38 PM
Event ID: 1012
Task Category: None
Level: Information
Keywords: Classic
User: N/A
Computer: THE_SERVER
Description:
Application 'C:\inetpub\wwwroot\the_app\' was recycled after detecting the app_offline file.
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="IIS AspNetCore Module V2" />
<EventID Qualifiers="0">1012</EventID>
<Level>4</Level>
<Task>0</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2019-02-27T18:56:38.000000000Z" />
<EventRecordID>1410136</EventRecordID>
<Channel>Application</Channel>
<Computer>THE_SERVER</Computer>
<Security />
</System>
<EventData>
<Data>Application 'C:\inetpub\wwwroot\the_app\' was recycled after detecting the app_offline file.</Data>
<Data>Process Id: 19388.</Data>
<Data>File Version: 12.2.18346.1. Description: IIS ASP.NET Core Module V2 Request Handler. Commit: 0f9ad16b096ca2535d77efd2ad27645449421b44</Data>
</EventData>
</Event>
Log Name: Application
Source: IIS AspNetCore Module V2
Date: 2/27/2019 1:56:38 PM
Event ID: 1006
Task Category: None
Level: Information
Keywords: Classic
User: N/A
Computer: THE_SERVER
Description:
Sent shutdown HTTP message to process '29772' and received http status '202'.
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="IIS AspNetCore Module V2" />
<EventID Qualifiers="0">1006</EventID>
<Level>4</Level>
<Task>0</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2019-02-27T18:56:38.000000000Z" />
<EventRecordID>1410137</EventRecordID>
<Channel>Application</Channel>
<Computer>THE_SERVER</Computer>
<Security />
</System>
<EventData>
<Data>Sent shutdown HTTP message to process '29772' and received http status '202'.</Data>
<Data>Process Id: 19388.</Data>
<Data>File Version: 12.2.18346.1. Description: IIS ASP.NET Core Module V2 Request Handler. Commit: 0f9ad16b096ca2535d77efd2ad27645449421b44</Data>
</EventData>
</Event>
Log Name: Application
Source: IIS AspNetCore Module V2
Date: 2/27/2019 1:56:38 PM
Event ID: 1030
Task Category: None
Level: Information
Keywords: Classic
User: N/A
Computer: THE_SERVER
Description:
Application '/LM/W3SVC/4/ROOT' with physical root 'C:\inetpub\wwwroot\the_app\' shut down process with Id '29772' listening on port '32531'
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="IIS AspNetCore Module V2" />
<EventID Qualifiers="0">1030</EventID>
<Level>4</Level>
<Task>0</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2019-02-27T18:56:38.000000000Z" />
<EventRecordID>1410138</EventRecordID>
<Channel>Application</Channel>
<Computer>THE_SERVER</Computer>
<Security />
</System>
<EventData>
<Data>Application '/LM/W3SVC/4/ROOT' with physical root 'C:\inetpub\wwwroot\the_app\' shut down process with Id '29772' listening on port '32531'</Data>
<Data>Process Id: 19388.</Data>
<Data>File Version: 12.2.18346.1. Description: IIS ASP.NET Core Module V2 Request Handler. Commit: 0f9ad16b096ca2535d77efd2ad27645449421b44</Data>
</EventData>
</Event>
Triage decisions:
Suggest considering this for 3.1. We don't have the capacity to do it in 3.0 given the current list of work.
I haven't seen reports of this recently. Is it still happening?
We are running default service mode SignalR with app services behind,
We do rolling deploys behind an application gateway and when shutting down a app service instance we get this in logs:
{"message":"Error when dispatching \u0027\u0022OnDisconnectedAsync\u0022\u0027 on hub.","id":"40685953-52b4-4d14-ba84-e7aab10b857b","fields":{"HubMethod":"OnDisconnectedAsync","EventId":"{ Id: 1, Name: \u0022ErrorDispatchingHubEvent\u0022 }","SourceContext":"Microsoft.AspNetCore.SignalR.HubConnectionHandler","NG_ServiceName":"TrumfAppBFF","NG_MachineName":"DW0SDWK000A6R","NG_Environment":"dev","SourceContextName":"HubConnectionHandler"},"messagetype":"structured","logger":"serilog","host":"DW0SDWK000A6R","app":"TrumfAppBFF","level":"ERROR","timestamp":"2024-09-12T16:56:30.413","exception":"System.ObjectDisposedException: Cannot access a disposed object.\r\nObject name: \u0027IServiceProvider\u0027.\r\n at Microsoft.Extensions.DependencyInjection.ServiceLookup.ThrowHelper.ThrowObjectDisposedException()\r\n at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateScope()\r\n at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.CreateAsyncScope(IServiceScopeFactory serviceScopeFactory)\r\n at Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher\u00601.OnDisconnectedAsync(HubConnectionContext connection, Exception exception)\r\n at Microsoft.AspNetCore.SignalR.HubConnectionHandler\u00601.HubOnDisconnectedAsync(HubConnectionContext connection, Exception exception)\r\n at Microsoft.AspNetCore.SignalR.HubConnectionHandler\u00601.RunHubAsync(HubConnectionContext connection)\r\n at Microsoft.AspNetCore.SignalR.HubConnectionHandler\u00601.OnConnectedAsync(ConnectionContext connection)\r\n at Microsoft.AspNetCore.SignalR.HubConnectionHandler\u00601.OnConnectedAsync(ConnectionContext connection)\r\n at Microsoft.Azure.SignalR.ServiceConnection.ProcessApplicationTaskAsyncCore(ClientConnectionContext connection)\r\n at Microsoft.Azure.SignalR.ServiceConnection.ProcessClientConnectionAsync(ClientConnectionContext connection)","templateHash":"9ac2dd74","logversion":"0"}
Describe the bug
After migrating my application from ASP.NET Core 2.1 (net471) to ASP.NET Core 2.2 (netcoreapp2.2 and InProcess hosting model) I found some exceptions in our log system related to SignalR.
These exceptions are always happening after IIS shutting down the application.
And I have some errors logged in the Event Viewer at the same time.
Additional context
Event Viewer logs
dotnet --info