title: ConnectionResetException: An existing connection was forcibly closed by the remote host on Rest API call for big file
body: <p>I have an C# WebAPI that let user upload file in chunks. The application works fine for http. But when I added https for my API I found out it works fine for small size of files, but for bigger file sizes (&gt;60MB) the request just waits for 2 minutes and then just fails. After looking at the server log I found this exception:</p>
  <pre><code>Microsoft.AspNetCore.Connections.ConnectionResetException: An existing connection was forcibly closed by the remote host.
   ---&gt; System.Net.Sockets.SocketException (10054): An existing connection was forcibly closed by the remote host.
     at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketAwaitableEventArgs.&lt;GetResult&gt;g__ThrowSocketException|5_0(SocketError e)
     at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketAwaitableEventArgs.GetResult(Int16 token)
     at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketConnection.DoReceive()
     --- End of inner exception stack trace ---
     at System.IO.Pipelines.Pipe.GetReadResult(ReadResult&amp; result)
     at System.IO.Pipelines.Pipe.GetReadAsyncResult()
     at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1ContentLengthMessageBody.ReadAsyncInternal(CancellationToken cancellationToken)
     at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource&lt;TResult&gt;.GetResult(Int16 token)
     at System.IO.Pipelines.PipeReader.CopyToAsyncCore[TStream](TStream destination, Func`4 writeAsync, CancellationToken cancellationToken)
     at Infrastructure.LocalStorage.Domain.UploadFile.UploadChunkFileStreamService.SaveFileChunkAsync(UploadFileCommand command, String fileChunkPath)
  </code></pre>
  <p>What's even more crazy is it works fine for one server (we set up https on dev environment) but not for the other server. In both cases we are using IIS. Any idea how we can fix this issue? Am I missing any IIS configuration for HTTPS?</p>
  <p>Note:</p>
  <ul>
  <li>we already made uploadReadAheadSize bigger to avoid 413 error.</li>
  <li>added the following code to my server as suggested on this <a href="https://stackoverflow.com/a/50746109/713847">post</a> (however that's a <code>SocketException</code> NOT <code>ConnectionResetException</code> although the message are same)</li>
  </ul>
  <pre><code>ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 
  </code></pre>
  <ul>
  <li>the file is being uploaded by a react app from the front-end.</li>
  </ul>