When IIS application pool recycles, all the ServiceStack SSE connections will be rebuilt. If there are a lot of connections, say 2000 or even more, a lot of exceptions are thrown on the server side. It says the connection is closed by the remote host(the client). I am wondering why this is happening.
Here is a sample of exception in servicestack log
2017-05-24 15:22:12,131: ERROR 14 EventSubscription - Error publishing notification to:
System.Web.HttpException (0x800704CD): The remote host closed the connection. The error code is 0x800704CD.
at System.Web.Hosting.IIS7WorkerRequest.RaiseCommunicationError(Int32 result, Boolean throwOnDisconnect)
at System.Web.Hosting.IIS7WorkerRequest.ExplicitFlush()
at System.Web.HttpResponse.Flush(Boolean finalFlush, Boolean async)
at System.Web.HttpResponse.Flush()
at System.Web.HttpWriter.WriteFromStream(Byte[] data, Int32 offset, Int32 size)
at System.Web.HttpResponseStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at ServiceStack.StreamExt.Write(Stream stream, String text)
at ServiceStack.ServerEventsFeature.<>c.<.ctor>b__76_0(IResponse res, String frame)
at ServiceStack.EventSubscription.PublishRaw(String frame)
The exception is because the long-running HTTP Connection that ServiceStack uses to publish Server Events no longer exists so writing to the Response Stream throws that Exception.
When this happens ServiceStack logs the error you see above and then automatically unsubscribes the Event subscription.
User contributions licensed under CC BY-SA 3.0