I run files on S3 through ajax requests and get errors ERR_CONNECTION_RESET about 50% of the time.
I know that the requests are signed correctly - any ideas that might be causing this? Again, this is an unsustainable problem that I see from several places and cars.
Here is the corresponding coffeescript code that I use to expose my files to S3. This comes from Mika Roberson and Rock Kruhl, working at http://micahroberson.com/upload-files-directly-to-s3-w-backbone-on-heroku/ and http://codeartists.com/post/36892733572/ how-to-directly-upload-files-to-amazon-s3-from-your .
createCORSRequest: (method, url) -> xhr = new XMLHttpRequest() if xhr.withCredentials? xhr.open method, url, true else if typeof XDomainRequest != "undefined" xhr = new XDomainRequest() xhr.open method, url else xhr = null xhr uploadToS3: (file, signature) -> this_s3upload = this this_s3upload.signature = signature url = signature.signed_request xhr = @createCORSRequest 'PUT', decodeURIComponent(signature.signed_request) if !xhr @onError 'CORS not supported' else xhr.onload = () -> if xhr.status == 200 this_s3upload.onProgress 100, 'Upload completed.' this_s3upload.onFinishS3Put file, this_s3upload.signature else this_s3upload.onError file, 'Upload error: ' + xhr.status xhr.onerror = () -> this_s3upload.onError file, 'XHR error.', this_s3upload.signature xhr.upload.onprogress = (e) -> if e.lengthComputable percentLoaded = Math.round (e.loaded / e.total) * 100 if percentLoaded == 100 message = "Finalizing" else message = "Uploading" this_s3upload.onProgress xhr, file, percentLoaded, message, this_s3upload.signature xhr.onabort = -> this_s3upload.onAbort file, "XHR cancelled by user.", this_s3upload.signature xhr.setRequestHeader 'Content-Type', file.type xhr.setRequestHeader 'x-amz-acl', 'public-read' xhr.send file
Update
I get very attentive support from Amazon on this. At their suggestion, I created an EC2 Windows instance, loaded the Chrome browser onto it, and tried to upload 5 files 10 times with my code. Once I did not see a mistake. Sometimes I saw some SignatureDoesNotMatch errors, but not one ERR_CONNECTION_RESET error. I still see ERR_CONNECTION_RESET errors, although in every EC2 client / network I use I use.
Refresh . There is no solution. I switched from using a self-calibrated signature algorithm to one provided by boto. However, it does not affect the ERR_CONNECTION_RESET problem.