I have a web application, developed with Visual Studio 2019, targeting .Net Framework 4.8 and using an Angular front end. In production, using IIS 10, after running without problems for well over two weeks, the application just stopped responding, requiring recycling of the application pool. We are struggling to figure out why.
In the application error logs, I found a lot of the following entries (this is just one example):
2022-06-03 08:49:05.300 -05:00 [ERR] Failed writing message. Aborting connection. System.InvalidOperationException: Writing is not allowed after writer was completed. at System.IO.Pipelines.Pipe.GetMemory(Int32 sizeHint) at System.IO.Pipelines.Pipe.DefaultPipeWriter.GetSpan(Int32 sizeHint)
at System.IO.Pipelines.PipeWriter.WriteAsync(ReadOnlyMemory`1 source, CancellationToken cancellationToken) at Microsoft.AspNetCore.SignalR.HubConnectionContext.d__49.MoveNext() 2022-06-03 08:49:06.643 -05:00 [WRN] Heartbeat took longer than ""00:00:01"" at ""2022-06-03T13:49:06.6435092+00:00"". 2022-06-03 08:49:07.955 -05:00 [WRN] Heartbeat took longer than ""00:00:01"" at ""2022-06-03T13:49:07.9557024+00:00"". 2022-06-03 08:49:09.158 -05:00 [WRN] Heartbeat took longer than ""00:00:01"" at ""2022-06-03T13:49:09.1585443+00:00"". 2022-06-03 08:49:10.267 -05:00 [WRN] Heartbeat took longer than ""00:00:01"" at ""2022-06-03T13:49:10.2676601+00:00"". 2022-06-03 08:49:11.283 -05:00 [WRN] Heartbeat took longer than ""00:00:01"" at ""2022-06-03T13:49:11.2830451+00:00"". 2022-06-03 08:49:12.298 -05:00 [WRN] Heartbeat took longer than ""00:00:01"" at ""2022-06-03T13:49:12.2984324+00:00"". 2022-06-03 08:49:13.313 -05:00 [WRN] Heartbeat took longer than ""00:00:01"" at ""2022-06-03T13:49:13.3138198+00:00"". 2022-06-03 08:49:14.329 -05:00 [WRN] Heartbeat took longer than ""00:00:01"" at ""2022-06-03T13:49:14.3292071+00:00"". 2022-06-03 08:49:15.344 -05:00 [WRN] Heartbeat took longer than ""00:00:01"" at ""2022-06-03T13:49:15.3445944+00:00"". 2022-06-03 08:49:16.359 -05:00 [WRN] Heartbeat took longer than ""00:00:01"" at ""2022-06-03T13:49:16.3599817+00:00"". 2022-06-03 08:49:17.375 -05:00 [WRN] Heartbeat took longer than ""00:00:01"" at ""2022-06-03T13:49:17.3753694+00:00"". 2022-06-03 08:49:18.390 -05:00 [WRN] Heartbeat took longer than ""00:00:01"" at ""2022-06-03T13:49:18.3907585+00:00"". 2022-06-03 08:49:19.406 -05:00 [WRN] Heartbeat took longer than ""00:00:01"" at ""2022-06-03T13:49:19.4061440+00:00"". 2022-06-03 08:49:20.421 -05:00 [WRN] Heartbeat took longer than ""00:00:01"" at ""2022-06-03T13:49:20.4215310+00:00"".
I did some research on the Signal R error (Microsoft.AspNetCore.SignalR (1.1.0)), and found it reported by multiple people here: https://github.com/dotnet/aspnetcore/issues/6701 No solution is offered, but one person commented that it may be “a benign error”. I don’t know either the cause of it, or whether it is serious.
Regarding the Heartbeat warning messages, my research suggests that they are caused because the CPU on the server is overworked. See, for example:How to resolve Heartbeat took longer than "00:00:01" failure?.
However, CPU monitoring shows that CPU usage never exceeded 20% at the time of the incident.
No relevant errors in IIS logs or Event Viewer logs.