Reputation: 1058
On an Azure-hosted web app we are currently developing we are getting a weird issue when uploading files, both as multipart form data and through AJAX requests. Intermittently, and with no real pattern that I can discern, when uploading files the browser is reporting that the connection has been reset, i.e. the server has terminated the connection. Fiddler offers me the most detailed error message:
HTTP/1.1 504 Fiddler - Send Failure
[Fiddler] SendRequest() failed: System.IO.IOException Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host. < An existing connection was forcibly closed by the remote host
This is only happening when running over HTTPS (the entire site is set up to redirect to HTTPS for all requests). If I remove this redirect, I can reliably upload over HTTP.
The forms and AJAX requests are being handled by async MVC controllers, which access the streams on any HttpPostedFileBase
objects that are in the post data - these streams are then uploaded to Azure Blob Storage. Although I'm not sure these controllers are even handling the requests, given the connection is being closed before the payload is fully uploaded?
Any ideas? Really tearing my hair out over this one.
Upvotes: 0
Views: 1919
Reputation: 1058
I found out (after a huge amount of digging) that this was caused by an incorrect MTU setting on my network; specifically, my FTTC's PPPoE connection had an MTU of 1492 instead of the expected 1500. A while ago BT recommended 1492 as the MTU but this has since changed. The slightly smaller MTU was causing excessive fragmentation of packets in transit, which were more susceptible to packet loss (given there were more of them). The reason my connection was being reset by the remote server (Azure) was down to packet loss - after several attempts to upload the file, all of which failed due to packet loss, the server had had enough and closed the connection.
A really weird issue all-in-all, but I was happy to find a fix!
Upvotes: 1