2

I am trying to upload file via API.

Built in .NET Core 3.1 using mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base Hosted in Azure Container Group

In the middleware in the pipeline I can see that response is 200. But somewhere at the end of the pipeline I am getting exception in the logs.

Because of this my SPA is getting (failed)net::ERR_CONNECTION_RESET in browser network tab.

Tried many different things like making file size to max on Kestrel. Increasing the timeout value on Kestrel.

options.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(15);
options.Limits.MaxRequestBodySize = null;

The method body is taking total of 66seconds when I added the stopwatch to collect the execution time before and after the method finish.

The whole api call which both accepting the uploaded 2 files and processing them before returning. The call invocation from the SPA is taking 2 minutes 30 seconds when checked in the chrome browser.

This issue is not happening when I directly run the api on my laptop via Visual Studio or when I run my API on my docker windows 10 desktop.

I've followed the following link to increase the timeout on the client side.

Can this be because of container hosted as Azure Container Instance and not sure that timeout from it.

I tried increasing time in Angular SPA, .net core set keep alive and even RequestHeadersTimeout to more than 10 minutes. Wondering where should I increase the time.

Here is the callstack of the exception.

**2020-07-07 10:27:15.544 +00:00 [INF] Processing done..**
2020-07-07 10:27:15.544 +00:00 [INF] Executing HttpStatusCodeResult, setting HTTP status code 200
2020-07-07 10:27:15.544 +00:00 [INF] Executed action TestCast.Controllers.TestCastController.Index (TestCast) in 69124.861ms
2020-07-07 10:27:15.545 +00:00 [INF] Executed endpoint 'TestCast.Controllers.TestCastController.Index (TestCast)'
2020-07-07 10:27:15.545 +00:00 [DBG] Connection id "0HM12BT51RIQ7" completed keep alive response.
2020-07-07 10:27:15.545 +00:00 [INF] Request finished in 69129.4114ms 200
2020-07-07 10:27:15.545 +00:00 [DBG] Connection id "0HM12BT51RIQ7", Request id "0HM12BT51RIQ7:00000002": started reading request body.
2020-07-07 10:27:15.546 +00:00 [INF] Connection id "0HM12BT51RIQ7", Request id "0HM12BT51RIQ7:00000002": the application completed without reading the entire request body.
2020-07-07 10:27:15.546 +00:00 [DBG] Connection id "0HM12BT51RIQ7" reset.
2020-07-07 10:27:15.546 +00:00 [DBG] Connection id "0HM12BT51RIQ7" sending FIN because: "Connection reset by peer"
2020-07-07 10:27:15.547 +00:00 [DBG] Connection id "0HM12BT51RIQ7" resumed.
2020-07-07 10:27:15.547 +00:00 [DBG] Connection id "0HM12BT51RIQ7" request processing ended abnormally.
Microsoft.AspNetCore.Connections.ConnectionResetException: Connection reset by peer
 ---> System.Net.Sockets.SocketException (104): Connection reset by peer
   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.ProcessSends()
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketConnection.DoSend()
   --- 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.Http1ContentLengthMessageBody.ReadAsyncInternal(CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1MessageBody.OnConsumeAsyncAwaited()
   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)
2020-07-07 10:27:15.550 +00:00 [DBG] Connection id "0HM12BT51RIQ7" disconnecting.

Here is my action with the logic to process the uploaded files removed.

[HttpPost("FileUpload")]
public async Task<IActionResult> Index([FromForm] List<IFormFile> files)
{
    
    // All code is removed for brevity

    **Log.Information("Processing done..");**

    return Ok();
}
coolcake
  • 2,917
  • 8
  • 42
  • 57
  • I have the same issue with .net core 3.1 in Redhat Openshift – Siraf Aug 19 '20 at 08:40
  • What are you trying to do? I was uploading a large file and some long operation in the same call. I break up it into two pieces. I upload the file, start asyn operation to process the file. But via other actions I keep getting the status of that long processing operation. – coolcake Aug 20 '20 at 00:20
  • you got any solution for this? – cdev Dec 04 '20 at 07:02

0 Answers0