Aspnetcore: ASP.NET Core 2.1: An existing connection was forcibly closed by the remote host

Created on 9 Aug 2018  ·  45Comments  ·  Source: dotnet/aspnetcore

2554

After migrating to the last version of asp net core 2.1 i start getting this exception:

An existing connection was forcibly closed by the remote host
Source:System.Private.CoreLib
InnerException:System.Net.Sockets.SocketException (10054): An existing connection was forcibly closed by the remote host
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketAwaitable.GetResult()
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketConnection.ProcessReceives()
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketConnection.DoReceive()
StackTrace:   at System.IO.Pipelines.PipeCompletion.ThrowLatchedException()
   at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result)
   at System.IO.Pipelines.Pipe.ReadAsync(CancellationToken token)
   at System.IO.Pipelines.Pipe.DefaultPipeReader.ReadAsync(CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1MessageBody.PumpAsync()
   at System.IO.Pipelines.PipeCompletion.ThrowLatchedException()
   at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result)
   at System.IO.Pipelines.Pipe.ReadAsync(CancellationToken token)
   at System.IO.Pipelines.Pipe.DefaultPipeReader.ReadAsync(CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.MessageBody.ReadAsync(Memory`1 buffer, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.ReadAsyncInternal(Memory`1 buffer, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.WebUtilities.FileBufferingReadStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.WebUtilities.StreamHelperExtensions.DrainAsync(Stream stream, ArrayPool`1 bytePool, Nullable`1 limit, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Mvc.Formatters.JsonInputFormatter.ReadRequestBodyAsync(InputFormatterContext context, Encoding encoding)
   at Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BodyModelBinder.BindModelAsync(ModelBindingContext bindingContext)
   at Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.BindModelAsync(ActionContext actionContext, IModelBinder modelBinder, IValueProvider valueProvider, ParameterDescriptor parameter, ModelMetadata metadata, Object value)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerBinderDelegateProvider.<>c__DisplayClass0_0.<<CreateBinderDelegate>g__Bind|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync() 
2018-08-08 11:49:39.2834|7-5000075-17ef1173-99f0-e8cb-299d-ca9d9791f087|Catalogo|ERROR|Mensaje:An existing connection was forcibly closed by the remote host
Source:System.Private.CoreLib
InnerException:System.Net.Sockets.SocketException (10054): An existing connection was forcibly closed by the remote host
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketAwaitable.GetResult()
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketConnection.ProcessReceives()
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketConnection.DoReceive()
StackTrace:   at System.IO.Pipelines.PipeCompletion.ThrowLatchedException()
   at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result)
   at System.IO.Pipelines.Pipe.ReadAsync(CancellationToken token)
   at System.IO.Pipelines.Pipe.DefaultPipeReader.ReadAsync(CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1MessageBody.PumpAsync()
   at System.IO.Pipelines.PipeCompletion.ThrowLatchedException()
   at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result)
   at System.IO.Pipelines.Pipe.ReadAsync(CancellationToken token)
   at System.IO.Pipelines.Pipe.DefaultPipeReader.ReadAsync(CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.MessageBody.ReadAsync(Memory`1 buffer, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.ReadAsyncInternal(Memory`1 buffer, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.WebUtilities.FileBufferingReadStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.WebUtilities.StreamHelperExtensions.DrainAsync(Stream stream, ArrayPool`1 bytePool, Nullable`1 limit, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Mvc.Formatters.JsonInputFormatter.ReadRequestBodyAsync(InputFormatterContext context, Encoding encoding)
   at Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BodyModelBinder.BindModelAsync(ModelBindingContext bindingContext)
   at Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.BindModelAsync(ActionContext actionContext, IModelBinder modelBinder, IValueProvider valueProvider, ParameterDescriptor parameter, ModelMetadata metadata, Object value)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerBinderDelegateProvider.<>c__DisplayClass0_0.<<CreateBinderDelegate>g__Bind|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync() 
area-servers servers-kestrel

Most helpful comment

we have the same error. our environment is azure VMs with a load balancer and 2+ machines. it reproduced time to time while image uploading (desktop firefox and chrome).

All 45 comments

@ufalak Looks like it's a benign client discosnnect. Is the issue that you started seeing this, or are there actual issues you're hitting?

It would be interesting to see this from actual logs (looks like you copied the stack traces from elsewhere.)

In fact, my principal problem is that i don really know what effect is taking for the client because i cant reproduce it.
I dont know wich conection its making closed and neither in wich condition and neither whats effect take to the client.

This is extracted from the log in production environment and i started to see this when i move to net core 2.1.

This are the lines before and the exception from the log:

2018-08-10 00:04:26.7687|2-18000120-d59dc782-36d1-c8e0-46a2-2763e7e93d6d|Microsoft.AspNetCore.Server.Kestrel|INFO|Connection id "0HLFTNI2LI4CL", Request id "0HLFTNI2LI4CL:00000016": the application completed without reading the entire request body.
2018-08-10 00:04:26.7687|2-18000120-d59dc782-36d1-c8e0-46a2-2763e7e93d6d|Microsoft.AspNetCore.Server.Kestrel|INFO|Connection id "0HLFTNI2LI4CL", Request id "0HLFTNI2LI4CL:00000016": the application completed without reading the entire request body.
2018-08-10 00:04:27.4154|2-18000120-d59dc782-36d1-c8e0-46a2-2763e7e93d6d|Catalogo|ERROR|Mensaje:An existing connection was forcibly closed by the remote host
Source:System.Private.CoreLib
InnerException:System.Net.Sockets.SocketException (10054): An existing connection was forcibly closed by the remote host
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketAwaitable.GetResult()
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketConnection.ProcessReceives()
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketConnection.DoReceive()
StackTrace: at System.IO.Pipelines.PipeCompletion.ThrowLatchedException()
at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result)
at System.IO.Pipelines.PipeCompletion.ThrowLatchedException()
at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result)
at System.IO.Pipelines.Pipe.GetReadAsyncResult()
at System.IO.Pipelines.Pipe.DefaultPipeReader.GetResult(Int16 token)
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketConnection.ProcessSends()
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1MessageBody.PumpAsync()
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketConnection.DoSend()
at System.IO.Pipelines.PipeCompletion.ThrowLatchedException()
at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result)
at System.IO.Pipelines.Pipe.GetReadAsyncResult()
at System.IO.Pipelines.Pipe.DefaultPipeReader.GetResult(Int16 token)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.MessageBody.ReadAsync(Memory1 buffer, CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.ReadAsyncInternal(Memory1 buffer, CancellationToken cancellationToken)
at Microsoft.AspNetCore.WebUtilities.FileBufferingReadStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
at Microsoft.AspNetCore.WebUtilities.StreamHelperExtensions.DrainAsync(Stream stream, ArrayPool1 bytePool, Nullable1 limit, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Mvc.Formatters.JsonInputFormatter.ReadRequestBodyAsync(InputFormatterContext context, Encoding encoding)
at Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BodyModelBinder.BindModelAsync(ModelBindingContext bindingContext)
at Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.BindModelAsync(ActionContext actionContext, IModelBinder modelBinder, IValueProvider valueProvider, ParameterDescriptor parameter, ModelMetadata metadata, Object value)
at Microsoft.AspNetCore.Mvc.Internal.ControllerBinderDelegateProvider.<>c__DisplayClass0_0.<g__Bind|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync()

Doesnt look that is the same error, because i dont get that much nested exceptions.
I need to know:
1) what exactly its throwing this exception of "An existing connection was forcibly closed by the remote host
Source:System.Private.CoreLib
InnerException:System.Net.Sockets.SocketException (10054): An existing connection was forcibly closed by the remote host"

2) What effect its causing to the user that is navigating the site at that moment?
3) how can i catch and take any action on this exception?

Thanks!

  1. what exactly its throwing this exception of "An existing connection was forcibly closed by the remote host
    Source:System.Private.CoreLib
    InnerException:System.Net.Sockets.SocketException (10054): An existing connection was forcibly closed by the remote host"

An internal call by the server to Socket.ReceiveAsync().

  1. What effect its causing to the user that is navigating the site at that moment?

Hopefully very little, because it's the client (e.g. browser, googlebot, etc...) that closed the connection while the JsonInputFormatter is in the middle of parsing the request body. This could happen because the user navigating the site closed the tab or browser, an ajax request was canceled programmatically, or many other reasons. This does mean that whatever controller action the upload was supposed to trigger never executes however.

  1. how can i catch and take any action on this exception?

It looks like you already are catching and logging the exception. The following

2018-08-10 00:04:27.4154|2-18000120-d59dc782-36d1-c8e0-46a2-2763e7e93d6d|Catalogo|ERROR|Mensaje:An existing connection was forcibly closed by the remote host

doesn't look like an ASP.NET log. The log source "Catalogo" isn't an ASP.NET namespace. You'll notice that the other logs include a namespace like "Microsoft.AspNetCore.Server.Kestrel" in the same place "Catalogo" appears in the above log. Those logs are logged directly by Kestrel with a relatively low "INFO" severity.

Thanks so much for your answer!
And, its a core bug that this its being throwed like and exception? Are you planing to change this to not to be and exception?

There will likely always be a so-called "first chance exception" for a connection reset to make it possible to distinguish resets from a graceful connection close. This isn't usually super important for HTTP connections since it's possible to determine whether the connection closed early by looking at things like the Content-Length header, but Kestrel has aspirations for being more than just an HTTP server.

Additionally, an incomplete request body will always result in an exception being thrown from HttpContext.Request.Body.ReadAsync() regardless of whether there was an underlying connection reset, because that's the way the server indicates to the app that the request body upload did not complete successfully.

Thanks again for your answer !
Yes, you are right, im catching the exception in global exception handler, but aprentlly this exception its something like "low importance".

So, there is any way that i can programatically distinguish wich this kind of "low important" exception to doesnt log it?
Because, if im understanding fine, i didnt need to take any action if i get this particularry socket exception.
(i supossed that not all the socketexception are "low importance" kind of).

There is any way to reproduce this "first chance exception" of a connection reset to test it?

I have same issue, not sure how to debug this:

System.IO.IOException:
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.IO.Pipelines.PipeCompletion.ThrowLatchedException (System.IO.Pipelines, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51)
   at System.IO.Pipelines.Pipe.GetFlushResult (System.IO.Pipelines, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51)
   at System.IO.Pipelines.Pipe.FlushAsync (System.IO.Pipelines, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51)
   at System.IO.Pipelines.Pipe+DefaultPipeWriter.FlushAsync (System.IO.Pipelines, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1OutputProducer.WriteAsync (Microsoft.AspNetCore.Server.Kestrel.Core, Version=2.1.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1OutputProducer.WriteDataAsync (Microsoft.AspNetCore.Server.Kestrel.Core, Version=2.1.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.WriteAsync (Microsoft.AspNetCore.Server.Kestrel.Core, Version=2.1.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpResponseStream.WriteAsync (Microsoft.AspNetCore.Server.Kestrel.Core, Version=2.1.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.AspNetCore.Http.Extensions.StreamCopyOperation+<CopyToAsync>d__2.MoveNext (Microsoft.AspNetCore.Http.Extensions, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.AspNetCore.StaticFiles.StaticFileContext+<SendAsync>d__49.MoveNext (Microsoft.AspNetCore.StaticFiles, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware+<Invoke>d__7.MoveNext (Microsoft.AspNetCore.StaticFiles, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware+<Invoke>d__6.MoveNext (Microsoft.AspNetCore.Diagnostics, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
Inner exception System.Net.Sockets.SocketException handled at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw:
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketAwaitable.GetResult (Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets, Version=2.1.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketConnection+<ProcessSends>d__26.MoveNext (Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets, Version=2.1.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketConnection+<DoSend>d__25.MoveNext (Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets, Version=2.1.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)

@nukec Are you seeing any issues other than the exception? Like I said in my last comment, here will likely always be a so-called "first chance exception" for a connection reset.

The issue is that its an unhandled scenario.
I need to be able to reproduce this exception and handle it.
This wasnt happen before the upgrade to net core 2.1 so i supposed its something new on this upgrade

But it looks like the exception is being handled. It's being thrown through Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware+<Invoke>d__7.MoveNext here. Even if no other middleware handles this exception, Kestrel does.

Yes, but its internally handled and i only handle this exception in my code as an "exception".
I need two things:

  1. how to exactly reproduce this exception
  2. how to exactly catch this particullary exception (not all the SocketException, just this one thrown from this place) to stop logging it because is aparentlly useless

@ufalak Can you provide the exception message for the IOException? I don't know where you're getting the exception details currently, but if you use ASP.NET Core's Logging Infrastructure it should include this information.

I write that before in my first comment

Or are you asking for somethig else?

@halter73 i resolved this by changing 32bit to 64bit app in azure for service app.

@ufalak The reason I ask is because you have two different exceptions in this issue. The exceptions in your first comment ("IOException: ... InnerException: SocketException (10054): An existing connection was forcibly closed by the remote host") was thrown during JsonInputFormatter.ReadRequestBodyAsync()'s call to Request.Body.ReadAsync(). Throwing for socket errors that occur while reading data from the client the expected behavior for Kestrel.

The exception message I'm interested in now is the one from your most recent comment which was thrown during StaticFileContext.SendAsync()'s call to Response.Body.WriteAsync(). If this was also caused by the same type of SocketException (which I don't see how it could be), this would be a bug in Kestrel because writing the the response body stream after the client prematurely disconnects is not supposed to raise an exception through Response.Body.WriteAsync() unless the RequestAborted CancellationToken is passed into the write call, but in that case you would get an OperationCanceledException instead of an IOException. Without a CancellationToken, the data written to the response body pipe basically goes to /dev/null since, as you mention, throwing an exception in this case would usually be useless.

So, long story short, if you can get the full exception message and stack trace together for the exception thrown from StaticFileContext.SendAsync(), that could be helpful to determine what exception we're not handling, because it can't be the same "SocketException (10054): ..." you saw from JsonInputFormatter.ReadRequestBodyAsync().

@halter73 it wasnt me the one who write that second exception.
It was @nukec.

Sorry for my confusion. @nukec Can you provide the exception message for the IOException you posted?

We're getting this error thousands of times a day in our 10 server web farm now we have gone out to production as of 2 days ago with a new site for processing user logins. It does not seem to correspond to a visible issue for the user. Can someone please confirm we're saying this is safe to be occurring and so really we should be looking at catching and suppressing the logging of this error?

@AlanMacdonald "SocketException (10054): An existing connection was forcibly closed by the remote host" simply means that a client disconnected ungracefully. This can happen if the client process exited mid-connection for example.

Usually this doesn't cause any issues visible to the user, since the user typically isn't concerned what happens on the server after a client closes the connection. That's why Kestrel logs this with a relatively low "INFO" severity. If the client disconnects in the middle of uploading a request body, that can cause HttpContext.Request.Body.ReadAsync() to throw leading to higher severity logs, but that's pretty rare.

@AlanMacdonald do you know what kind of devices you users are on? You'll see more ungraceful disconnects for mobile clients than for desktops for example.

@halter73 thanks for the info.

@benaadams it's mainly desktop users but the login site where this is occurring is identityserver4 so there could be things happening internal there maybe or it could be something with our backchannel communication between main site and login site but that all seems to be hanging together. Thanks

we have the same error. our environment is azure VMs with a load balancer and 2+ machines. it reproduced time to time while image uploading (desktop firefox and chrome).

I am having the same exception stack trace, with a WRN level, not INF. In my case, the application is .Net Core 2.1, running in a linux docker container in Rancher, where the health controller is being hit constantly by Rancher. I was on packege Microsoft.AspNetCore version 2.1.7, I am downgrading to Microsoft.AspNetCore 2.1.4 to see if that mitigates the issue.

I am also having this problem, but only when I import certain .js files into webpack. Even on a Release build where there is no webpack middleware or HMR used it still throws this.

After not including the offending .js file this error will continue until VS is restarted, not just by stopping and starting debugging.

System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

--- End of inner exception stack trace ---

at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.GetResult(Int16 token)
at System.Net.Http.HttpConnection.FillAsync()
at System.Net.Http.HttpConnection.ReadNextResponseHeaderLineAsync(Boolean foldedHeadersAllowed)
at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)

--- End of inner exception stack trace ---

at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithNtConnectionAuthAsync(HttpConnection connection, HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at Microsoft.AspNetCore.SpaServices.Webpack.ConditionalProxyMiddleware.PerformProxyRequest(HttpContext context)
at Microsoft.AspNetCore.SpaServices.Webpack.ConditionalProxyMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.SpaServices.Webpack.ConditionalProxyMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Which is very odd, does this somehow have to do with the size of included files, or their contents? I can't make heads or tails of it.

.net core 2.2.4
2019-04-26 06:30:02.6617 Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware
An unhandled exception has occurred while executing the request.
Microsoft.AspNetCore.Connections.ConnectionResetException:An existing connection was forcibly closed by the remote host ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketAwaitableEventArgs.g__ThrowSocketException|7_0(SocketError e)
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketAwaitableEventArgs.GetResult()
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketConnection.ProcessReceives()
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketConnection.DoReceive()
--- End of inner exception stack trace ---
at System.IO.Pipelines.PipeCompletion.ThrowLatchedException()
at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result)
at System.IO.Pipelines.Pipe.GetReadAsyncResult()
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1MessageBody.PumpAsync()
at System.IO.Pipelines.PipeCompletion.ThrowLatchedException()
at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result)
at System.IO.Pipelines.Pipe.GetReadAsyncResult()
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.MessageBody.ReadAsync(Memory1 buffer, CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.ReadAsyncInternal(Memory1 buffer, CancellationToken cancellationToken)
at System.IO.StreamReader.ReadBufferAsync()
at System.IO.StreamReader.ReadAsyncInternal(Memory1 buffer, CancellationToken cancellationToken) at Microsoft.AspNetCore.WebUtilities.FormReader.BufferAsync(CancellationToken cancellationToken) at Microsoft.AspNetCore.WebUtilities.FormReader.ReadNextPairAsyncImpl(CancellationToken cancellationToken) at Microsoft.AspNetCore.WebUtilities.FormReader.ReadFormAsync(CancellationToken cancellationToken) at Microsoft.AspNetCore.Http.Features.FormFeature.InnerReadFormAsync(CancellationToken cancellationToken) at Microsoft.AspNetCore.Mvc.ModelBinding.FormValueProviderFactory.AddValueProviderAsync(ValueProviderFactoryContext context) at Microsoft.AspNetCore.Mvc.ModelBinding.CompositeValueProvider.CreateAsync(ActionContext actionContext, IList1 factories)
at Microsoft.AspNetCore.Mvc.ModelBinding.CompositeValueProvider.CreateAsync(ControllerContext controllerContext)
at Microsoft.AspNetCore.Mvc.Internal.ControllerBinderDelegateProvider.<>c__DisplayClass0_0.<g__Bind|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ExceptionContext context)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.Invoke(HttpContext context) at System.IO.Pipelines.PipeCompletion.ThrowLatchedException()
at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result)
at System.IO.Pipelines.Pipe.GetReadAsyncResult()
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1MessageBody.PumpAsync()
at System.IO.Pipelines.PipeCompletion.ThrowLatchedException()
at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result)
at System.IO.Pipelines.Pipe.GetReadAsyncResult()
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.MessageBody.ReadAsync(Memory1 buffer, CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.ReadAsyncInternal(Memory1 buffer, CancellationToken cancellationToken)
at System.IO.StreamReader.ReadBufferAsync()
at System.IO.StreamReader.ReadAsyncInternal(Memory1 buffer, CancellationToken cancellationToken) at Microsoft.AspNetCore.WebUtilities.FormReader.BufferAsync(CancellationToken cancellationToken) at Microsoft.AspNetCore.WebUtilities.FormReader.ReadNextPairAsyncImpl(CancellationToken cancellationToken) at Microsoft.AspNetCore.WebUtilities.FormReader.ReadFormAsync(CancellationToken cancellationToken) at Microsoft.AspNetCore.Http.Features.FormFeature.InnerReadFormAsync(CancellationToken cancellationToken) at Microsoft.AspNetCore.Mvc.ModelBinding.FormValueProviderFactory.AddValueProviderAsync(ValueProviderFactoryContext context) at Microsoft.AspNetCore.Mvc.ModelBinding.CompositeValueProvider.CreateAsync(ActionContext actionContext, IList1 factories)
at Microsoft.AspNetCore.Mvc.ModelBinding.CompositeValueProvider.CreateAsync(ControllerContext controllerContext)
at Microsoft.AspNetCore.Mvc.Internal.ControllerBinderDelegateProvider.<>c__DisplayClass0_0.<g__Bind|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ExceptionContext context)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.Invoke(HttpContext context)

We faced the same exception when performing the load testing for an App Service.
`Stack Trace

at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult) at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)`

Hello,
Any progress or hints on that one?
As @tahiralvi, I've faced this issue when doing load tests.

Microsoft.AspNetCore.Connections.ConnectionResetException:
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.IO.Pipelines.PipeCompletion.ThrowLatchedException (System.IO.Pipelines, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51)
at System.IO.Pipelines.Pipe.GetReadResult (System.IO.Pipelines, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51)
at System.IO.Pipelines.Pipe.GetReadAsyncResult (System.IO.Pipelines, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1MessageBody+d__4.MoveNext (Microsoft.AspNetCore.Server.Kestrel.Core, Version=2.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.IO.Pipelines.PipeCompletion.ThrowLatchedException (System.IO.Pipelines, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51)
at System.IO.Pipelines.Pipe.GetReadResult (System.IO.Pipelines, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51)
at System.IO.Pipelines.Pipe.GetReadAsyncResult (System.IO.Pipelines, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.MessageBody+d__21.MoveNext (Microsoft.AspNetCore.Server.Kestrel.Core, Version=2.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream+d__22.MoveNext (Microsoft.AspNetCore.Server.Kestrel.Core, Version=2.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.AspNetCore.WebUtilities.BufferedReadStream+d__37.MoveNext (Microsoft.AspNetCore.WebUtilities, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.AspNetCore.WebUtilities.MultipartReaderStream+d__36.MoveNext (Microsoft.AspNetCore.WebUtilities, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.AspNetCore.WebUtilities.FileBufferingReadStream+d__35.MoveNext (Microsoft.AspNetCore.WebUtilities, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.AspNetCore.WebUtilities.StreamHelperExtensions+d__3.MoveNext (Microsoft.AspNetCore.WebUtilities, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.AspNetCore.Http.Features.FormFeature+d__18.MoveNext (Microsoft.AspNetCore.Http, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.AspNetCore.Mvc.ModelBinding.FormValueProviderFactory+d__1.MoveNext (Microsoft.AspNetCore.Mvc.Core, Version=2.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.AspNetCore.Mvc.ModelBinding.CompositeValueProvider+d__3.MoveNext (Microsoft.AspNetCore.Mvc.Core, Version=2.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.AspNetCore.Mvc.ModelBinding.CompositeValueProvider+d__2.MoveNext (Microsoft.AspNetCore.Mvc.Core, Version=2.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.AspNetCore.Mvc.Internal.ControllerBinderDelegateProvider+<>c__DisplayClass0_0+<g__Bind|0>d.MoveNext (Microsoft.AspNetCore.Mvc.Core, Version=2.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+d__13.MoveNext (Microsoft.AspNetCore.Mvc.Core, Version=2.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+d__23.MoveNext (Microsoft.AspNetCore.Mvc.Core, Version=2.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow (Microsoft.AspNetCore.Mvc.Core, Version=2.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next (Microsoft.AspNetCore.Mvc.Core, Version=2.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+d__18.MoveNext (Microsoft.AspNetCore.Mvc.Core, Version=2.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+d__16.MoveNext (Microsoft.AspNetCore.Mvc.Core, Version=2.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.AspNetCore.Builder.RouterMiddleware+d__4.MoveNext (Microsoft.AspNetCore.Routing, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware+d__6.MoveNext (Microsoft.AspNetCore.Diagnostics, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
Inner exception System.Net.Sockets.SocketException handled at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw:
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketAwaitable.GetResult (Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets, Version=2.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketConnection+d__25.MoveNext (Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets, Version=2.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketConnection+d__24.MoveNext (Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets, Version=2.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)

@AlanMacdonald "SocketException (10054): An existing connection was forcibly closed by the remote host" simply means that a client disconnected ungracefully. This can happen if the client process exited mid-connection for example.

Usually this doesn't cause any issues visible to the user, since the user typically isn't concerned what happens on the server after a client closes the connection. That's why Kestrel logs this with a relatively low "INFO" severity. If the client disconnects in the middle of uploading a request body, that can cause HttpContext.Request.Body.ReadAsync() to throw leading to higher severity logs, but that's pretty rare.

If it is frequently what will be the performance of the site.

We run into the similar issue on asp.net core 2.2.6 during executing POST request:

Microsoft.AspNetCore.Connections.ConnectionResetException: An existing connection was forcibly closed by the remote host ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

   at int Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketAwaitableEventArgs.GetResult()+ThrowSocketException(SocketError e)

   at int Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketAwaitableEventArgs.GetResult()

   at async Task Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketConnection.ProcessReceives()

   at async Task Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketConnection.DoReceive()

   --- End of inner exception stack trace ---

   at System.IO.Pipelines.PipeCompletion.ThrowLatchedException()

   at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result)

   at System.IO.Pipelines.Pipe.ReadAsync(CancellationToken token)

   at System.IO.Pipelines.Pipe.DefaultPipeReader.ReadAsync(CancellationToken cancellationToken)

   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1Connection.BeginRead(ValueTask`1& awaitable)

   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequestsAsync[TContext](IHttpApplication`1 application)

Hello @halter73! Perhaps you know how to fix it?

@Rody66 Generally it just means a client disconnected in the middle of uploading a request body.

In 3.0, we're lowering the severity of most logs caused by client connection errors to Debug instead of Info. #12262

I'm not sure the lower severity really helps much in this case because Kestrel doesn't buffer request bodies. This means Kestrel starts executing request middleware before the full request body is uploaded. If the client disconnects mid request-body, Kestrel doesn't have much choice other than to throw an exception. If that exception is uncaught, it will get logged as an error.

If you just want to fix the logs, you could try enabling buffering and drain the entire request body in a try/catch. In the catch, you can log the issue with whatever severity you want. If you successfully read the full body, you can set request.Body.Position back to zero and read again from your main app without any concern over seeing an IOException.

I am getting the same error message core 2.2.4

Microsoft.AspNetCore.Server.Kestrel|Connection id “0HLP5AO39QCJI”, Request id “0HLP5AO39QCJI:00000017”: An unhandled exception was thrown by the application. Microsoft.AspNetCore.Connections.ConnectionResetException: An existing connection was forcibly closed by the remote host ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketAwaitableEventArgs.<GetResult>g__ThrowSocketException|7_0(SocketError e)
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketAwaitableEventArgs.GetResult()
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketConnection.ProcessReceives()
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketConnection.DoReceive()
--- End of inner exception stack trace ---
at System.IO.Pipelines.PipeCompletion.ThrowLatchedException()
at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result)
at System.IO.Pipelines.Pipe.GetReadAsyncResult()
at System.IO.Pipelines.Pipe.DefaultPipeReader.GetResult(Int16 token)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1MessageBody.PumpAsync()
at System.IO.Pipelines.PipeCompletion.ThrowLatchedException()
at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result)
at System.IO.Pipelines.Pipe.GetReadAsyncResult()
at System.IO.Pipelines.Pipe.DefaultPipeReader.GetResult(Int16 token)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.MessageBody.ReadAsync(Memory`1 buffer, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.ReadAsyncInternal(Memory`1 buffer, CancellationToken cancellationToken)
at Microsoft.AspNetCore.WebUtilities.FileBufferingReadStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
at Microsoft.AspNetCore.WebUtilities.StreamHelperExtensions.DrainAsync(Stream stream, ArrayPool`1 bytePool, Nullable`1 limit, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Mvc.Formatters.JsonInputFormatter.ReadRequestBodyAsync(InputFormatterContext context, Encoding encoding)
at Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BodyModelBinder.BindModelAsync(ModelBindingContext bindingContext)
at Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.BindModelAsync(ActionContext actionContext, IModelBinder modelBinder, IValueProvider valueProvider, ParameterDescriptor parameter, ModelMetadata metadata, Object value)
at Microsoft.AspNetCore.Mvc.Internal.ControllerBinderDelegateProvider.<>c__DisplayClass0_0.<<CreateBinderDelegate>g__Bind|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---

at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
at Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.InvokeCore(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Server.IISIntegration.IISMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

One of my customers has reported an issue of not being able to log on to my site, I did a call with him and have been able to correspond the above error message with him as every time we where on the phone and he did something on the site 2 seconds later I had in my inbox the above error message.

It was hard to see what was going on as his connection seems very slow(which maybe the problem??). I asked him to do a speed test and he had 2mbps with 109ms ping.

when I could see the chrome developer console I saw tons of connections refused in it.

He was trying to use the site normally(not loading the site up and closing the tab right away and etc).

@chobo2 As I mentioned in my last comment, generally this error means that a client disconnected in the middle of uploading a request body. This certainly could be caused by a spotty connection, but there are other possible causes like the client intentionally cancelling a request mid-request-body.

when I could see the chrome developer console I saw tons of connections refused in it.

Can you provide us with a screenshot/logs from the network tab of the developer console?

@chobo2 As I mentioned in my last comment, generally this error means that a client disconnected in the middle of uploading a request body. This certainly could be caused by a spotty connection, but there are other possible causes like the client intentionally cancelling a request mid-request-body.

when I could see the chrome developer console I saw tons of connections refused in it.

Can you provide us with a screenshot/logs from the network tab of the developer console?

I will try to get the developer console, it is jsut hard as screen sharing is like nightmare and the customer is not skilled enough to do it themselves.

They claim no other site has problems expect mine though I can verify this and only can go by what I saw(like losing screens sharing many times).

I am also facing the issue in our prod environment. Do we have a solution for the above issue?

Same issue here as well in our prod environment. Happens intermittently.

Dear developers, please fix this exception. It's like a client error.

Since I upgraded to core 3.0, I don't have this exception

@jpmaistrebazin

I maybe wrong, but I think I read in 3.0 they just don't log the error in the same way or same error level and that's why your logger does not pick it up anymore.

We try to make sure that we don't log this exception with too high of a severity in most circumstances like when reading request headers. However, if this kind of exception happens in the middle of a request body, app middleware is already running. This means an exception must be thrown from HttpContext.Request.Body.ReadAsync(), since it would be worse to pretend the request body completed gracefully.

This is what the logs show happened in the original issue. In this case, the exception will still be logged as an error if the app middleware doesn't swallow the exception.

Hi,

I installed a new TFS build agent in a new server. When i run the build, i am getting below error in dotnet restore task :

2020-06-29T11:02:19.1809398Z ##[section]Starting: dotnet restore
2020-06-29T11:02:19.1819409Z ==============================================================================
2020-06-29T11:02:19.1819409Z Task : .NET Core
2020-06-29T11:02:19.1819409Z Description : Build, test and publish using dotnet core command-line.
2020-06-29T11:02:19.1819409Z Version : 1.0.1
2020-06-29T11:02:19.1819409Z Author : Microsoft Corporation
2020-06-29T11:02:19.1819409Z Help : More Information
2020-06-29T11:02:19.1819409Z ==============================================================================
2020-06-29T11:02:24.1662394Z [command]"C:\Program Files\dotnet\dotnet.exe" restore D:\Agent_work\1\s\Elio.Utility\Elio.Utility.csproj
2020-06-29T11:02:35.3179014Z C:\Program Files\dotnet\sdk\2.1.701\NuGet.targets(121,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [D:\Agent_work\1\s\Elio.Utility\Elio.Utility.csproj]
2020-06-29T11:02:35.3309105Z C:\Program Files\dotnet\sdk\2.1.701\NuGet.targets(121,5): error : The SSL connection could not be established, see inner exception. [D:\Agent_work\1\s\Elio.Utility\Elio.Utility.csproj]
2020-06-29T11:02:35.3489045Z C:\Program Files\dotnet\sdk\2.1.701\NuGet.targets(121,5): error : Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. [D:\Agent_work\1\s\Elio.Utility\Elio.Utility.csproj]
2020-06-29T11:02:35.3589051Z C:\Program Files\dotnet\sdk\2.1.701\NuGet.targets(121,5): error : An existing connection was forcibly closed by the remote host [D:\Agent_work\1\s\Elio.Utility\Elio.Utility.csproj]
2020-06-29T11:02:36.1129521Z ##[error]Error: C:\Program Files\dotnet\dotnet.exe failed with return code: 1
2020-06-29T11:02:36.1129521Z [command]"C:\Program Files\dotnet\dotnet.exe" restore D:\Agent_work\1\s\PlanManager.API.ComponentLogic\PlanManager.API.ComponentLogic.csproj
2020-06-29T11:02:50.6828191Z C:\Program Files\dotnet\sdk\2.1.701\NuGet.targets(121,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [D:\Agent_work\1\s\PlanManager.API.ComponentLogic\PlanManager.API.ComponentLogic.csproj]
2020-06-29T11:02:50.6918496Z C:\Program Files\dotnet\sdk\2.1.701\NuGet.targets(121,5): error : The SSL connection could not be established, see inner exception. [D:\Agent_work\1\s\PlanManager.API.ComponentLogic\PlanManager.API.ComponentLogic.csproj]
2020-06-29T11:02:50.6928205Z C:\Program Files\dotnet\sdk\2.1.701\NuGet.targets(121,5): error : Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. [D:\Agent_work\1\s\PlanManager.API.ComponentLogic\PlanManager.API.ComponentLogic.csproj]
2020-06-29T11:02:50.7058218Z C:\Program Files\dotnet\sdk\2.1.701\NuGet.targets(121,5): error : An existing connection was forcibly closed by the remote host [D:\Agent_work\1\s\PlanManager.API.ComponentLogic\PlanManager.API.ComponentLogic.csproj]
2020-06-29T11:02:50.9918396Z ##[error]Error: C:\Program Files\dotnet\dotnet.exe failed with return code: 1
2020-06-29T11:02:51.0258406Z [command]"C:\Program Files\dotnet\dotnet.exe" restore D:\Agent_work\1\s\PlanManager.API.DataAccessLogic\PlanManager.API.DataAccessLogic.csproj
2020-06-29T11:02:59.5673478Z C:\Program Files\dotnet\sdk\2.1.701\NuGet.targets(121,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [D:\Agent_work\1\s\PlanManager.API.DataAccessLogic\PlanManager.API.DataAccessLogic.csproj]
2020-06-29T11:02:59.5803507Z C:\Program Files\dotnet\sdk\2.1.701\NuGet.targets(121,5): error : The SSL connection could not be established, see inner exception. [D:\Agent_work\1\s\PlanManager.API.DataAccessLogic\PlanManager.API.DataAccessLogic.csproj]
2020-06-29T11:02:59.5823510Z C:\Program Files\dotnet\sdk\2.1.701\NuGet.targets(121,5): error : Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. [D:\Agent_work\1\s\PlanManager.API.DataAccessLogic\PlanManager.API.DataAccessLogic.csproj]
2020-06-29T11:02:59.5823510Z C:\Program Files\dotnet\sdk\2.1.701\NuGet.targets(121,5): error : An existing connection was forcibly closed by the remote host [D:\Agent_work\1\s\PlanManager.API.DataAccessLogic\PlanManager.API.DataAccessLogic.csproj]
2020-06-29T11:02:59.9073696Z ##[error]Error: C:\Program Files\dotnet\dotnet.exe failed with return code: 1
2020-06-29T11:02:59.9073696Z [command]"C:\Program Files\dotnet\dotnet.exe" restore D:\Agent_work\1\s\PlanManager.API.Entities\PlanManager.API.Entities.csproj
2020-06-29T11:03:06.7377820Z C:\Program Files\dotnet\sdk\2.1.701\NuGet.targets(121,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [D:\Agent_work\1\s\PlanManager.API.Entities\PlanManager.API.Entities.csproj]
2020-06-29T11:03:06.7657829Z C:\Program Files\dotnet\sdk\2.1.701\NuGet.targets(121,5): error : The SSL connection could not be established, see inner exception. [D:\Agent_work\1\s\PlanManager.API.Entities\PlanManager.API.Entities.csproj]
2020-06-29T11:03:06.8407882Z C:\Program Files\dotnet\sdk\2.1.701\NuGet.targets(121,5): error : Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. [D:\Agent_work\1\s\PlanManager.API.Entities\PlanManager.API.Entities.csproj]
2020-06-29T11:03:06.8477884Z C:\Program Files\dotnet\sdk\2.1.701\NuGet.targets(121,5): error : An existing connection was forcibly closed by the remote host [D:\Agent_work\1\s\PlanManager.API.Entities\PlanManager.API.Entities.csproj]
2020-06-29T11:03:07.0267990Z ##[error]Error: C:\Program Files\dotnet\dotnet.exe failed with return code: 1
2020-06-29T11:03:07.0308001Z [command]"C:\Program Files\dotnet\dotnet.exe" restore D:\Agent_work\1\s\PlanManager.API\PlanManager.API.csproj
2020-06-29T11:03:14.8222593Z C:\Program Files\dotnet\sdk\2.1.701\NuGet.targets(121,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [D:\Agent_work\1\s\PlanManager.API\PlanManager.API.csproj]
2020-06-29T11:03:14.8472632Z C:\Program Files\dotnet\sdk\2.1.701\NuGet.targets(121,5): error : The SSL connection could not be established, see inner exception. [D:\Agent_work\1\s\PlanManager.API\PlanManager.API.csproj]
2020-06-29T11:03:14.8592641Z C:\Program Files\dotnet\sdk\2.1.701\NuGet.targets(121,5): error : Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. [D:\Agent_work\1\s\PlanManager.API\PlanManager.API.csproj]
2020-06-29T11:03:14.8602633Z C:\Program Files\dotnet\sdk\2.1.701\NuGet.targets(121,5): error : An existing connection was forcibly closed by the remote host [D:\Agent_work\1\s\PlanManager.API\PlanManager.API.csproj]
2020-06-29T11:03:15.1182808Z ##[error]Error: C:\Program Files\dotnet\dotnet.exe failed with return code: 1
2020-06-29T11:03:15.1222804Z ##[error]Dotnet command failed with non-zero exit code on the following projects : D:\Agent_work\1\s\Elio.Utility\Elio.Utility.csproj,D:\Agent_work\1\s\PlanManager.API.ComponentLogic\PlanManager.API.ComponentLogic.csproj,D:\Agent_work\1\s\PlanManager.API.DataAccessLogic\PlanManager.API.DataAccessLogic.csproj,D:\Agent_work\1\s\PlanManager.API.Entities\PlanManager.API.Entities.csproj,D:\Agent_work\1\s\PlanManager.API\PlanManager.API.csproj
2020-06-29T11:03:15.2092851Z ##[section]Finishing: dotnet restore

Please suggest what i am missing.

Thanks in advance.

Regards
Govindarajan S

@govindarajan69 The issue you're experiencing seems not to be related to a client abruptly disconnecting from an ASP.NET Core app running on Kestrel like in the original issue.

I suggest creating a new issue at https://github.com/nuget/home/issues to find out why the NuGet MSBuild target is getting SocketException during the TLS handshake while trying to connect to api.nuget.org. I suspect the api.nuget.org server doesn't like an outdated TLS version or algorithm the client is trying to use.

I'm having a quite similar issue

2020-09-02 05:35:46.993 +01:00 [ERR] An unhandled exception has occurred while executing the request.
System.Net.Http.HttpRequestException: Error while copying content to a stream.
---> System.IO.IOException: Unable to read data from the transport connection: An established connection was aborted by the software in your host machine..
---> System.Net.Sockets.SocketException (10053): An established connection was aborted by the software in your host machine.
--- End of inner exception stack trace ---
at System.Net.Security.SslStream.g__CompleteAsync|210_1TWriteAdapter
at System.Net.Security.SslStream.WriteAsyncChunkedTWriteAdapter
at System.Net.Http.HttpConnection.WriteAsync(ReadOnlyMemory1 source) at System.Net.Http.HttpContent.CopyToAsyncCore(ValueTask copyTask) --- End of inner exception stack trace --- at System.Net.Http.HttpContent.CopyToAsyncCore(ValueTask copyTask) at System.Net.Http.HttpConnection.SendRequestContentAsync(HttpRequestMessage request, HttpContentWriteStream stream, CancellationToken cancellationToken) at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithNtConnectionAuthAsync(HttpConnection connection, HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.DiagnosticsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at Microsoft.Extensions.Http.Logging.LoggingHttpMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at MerchantBackend.Infrastructure.Processors.BapService.OnboardMerchantAsync(MerchantOnboardingRequest request) in C:\Userstmp10513\Documents\workspacefirst-bills-payMerchant-BackendMerchantBackend.InfrastructureProcessorsBapService.cs:line 48
at MerchantBackend.Core.UseCaseHandlers.MerchantOnboarding.CompleteMerchantOnboardingHandler.Handle(CompleteMerchantOnboardingCommand request, CancellationToken cancellationToken) in C:\Userstmp10513\Documents\workspacefirst-bills-payMerchant-BackendMerchantBackend.Core\UseCaseHandlersMerchantOnboarding\CompleteMerchantOnboardingHandler.cs:line 132
at MerchantBackend.Core.Behaviors.RequestValidationBehavior2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next) in C:\Userstmp10513\Documents\workspacefirst-bills-payMerchant-BackendMerchantBackend.CoreBehaviors\RequestValidationBehavior.cs:line 30
at MerchantBackend.Core.Behaviors.AuthorizationBehavior2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next) in C:\Userstmp10513\Documents\workspacefirst-bills-payMerchant-BackendMerchantBackend.CoreBehaviorsAuthorizationBehavior.cs:line 61
at MediatR.Pipeline.RequestExceptionProcessorBehavior2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next)
at MediatR.Pipeline.RequestExceptionProcessorBehavior2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next)
at MediatR.Pipeline.RequestExceptionActionProcessorBehavior2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next)
at MediatR.Pipeline.RequestExceptionActionProcessorBehavior2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next)
at MediatR.Pipeline.RequestPostProcessorBehavior2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next)
at MediatR.Pipeline.RequestPreProcessorBehavior2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next)
at MerchantBackend.Client.Controllers.MerchantsController.CompleteOnboarding(CompleteMerchantOnboardingRequest request) in C:\Userstmp10513\Documents\workspacefirst-bills-payMerchant-BackendMerchantBackend.Client\ControllersMerchantsController.cs:line 60
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)

Please any suggestions?

@IAmThatG This issue is about server-side exceptions related to connections being forcibly closed by the remote host mid-request. Your comment appears to be about client-side exceptions related to connections being aborted on your host with HttpClient. In both cases the implication is that it was the client, not the server, that closed the connection mid-request.

If anyone on this thread still thinks it's the server closing the connection mid-request can you enable (preferably trace-level) ASP.NET Core Logging and provide the logs from when the issue occurs in a new issue? Too many different issues are being discussed here, and they all seem to be caused by the client.

Was this page helpful?
0 / 5 - 0 ratings