Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon S3/Accelerated bucket upload fails ONLY for slow connection users

We're enabling our users to upload videos onto our Amazon S3 bucket. It's been fitted with the "acceleration" option and using Multi-Part upload from our JS. However, we've noticed something very disturbing: We have thousands of successful uploads from countries where the Internet is fast.

However, virtually all slow connection users (who all happen to be from places the internet isn't famous for speed) fail to upload. Once they do begin to upload they get dozens these errors on their console and the upload gets stuck and fails.

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://our-secret-bucket-xxxxxx.s3-accelerate.amazonaws.com/tyoeu/Abbey%…BAYmLRf4.YqtrWLwkD9uc5wGp0.rpyIV6xqDHxHqNaEsaxQTMAHs3g8DXdL3. (Reason: CORS request did not succeed).

The CORS setup for this bucket is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
    <AllowedOrigin>*</AllowedOrigin>
    <AllowedMethod>PUT</AllowedMethod>
    <AllowedMethod>POST</AllowedMethod>
    <AllowedMethod>GET</AllowedMethod>
    <AllowedMethod>HEAD</AllowedMethod>
    <MaxAgeSeconds>43200</MaxAgeSeconds>
    <ExposeHeader>ETag</ExposeHeader>
    <AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>

We help the upload failed users manually by asking them to upload to dropbox and share a link with us -- but this is just another proof something is wrong -- if they can upload to Dropbox with their slow connections, why can't they upload to AWS/S3? This has been gnawing at our souls for quite some time now and we can't understand what's wrong.

Surely we're not the only company on planet Earth allowing folks from around the world to upload large files. Why are we failing with slow connection users?

like image 464
JasonGenX Avatar asked Jul 16 '19 16:07

JasonGenX


2 Answers

Seems like this may be a request timeout issue, have you tried changing your aws.config.httpOptions.timeout? This defaults to two minutes but you can completely remove the timeout by setting it to zero. More info on this can be found here.

Edited to fix broken link.

like image 75
ketcham Avatar answered Oct 02 '22 18:10

ketcham


Please try following steps

1.Create a non accelerated version of s3 bucket and try with those users. If it works then create a program to copy over. I am not sure why Cors is there.

2.Using the Amazon S3 Transfer Acceleration Speed Comparison Tool

  1. try dual stack Transfer data to and from the acceleration-enabled bucket by using one of the following s3-accelerate endpoint domain names:

bucketname.s3-accelerate.amazonaws.com – to access an acceleration-enabled bucket.

bucketname.s3-accelerate.dualstack.amazonaws.com – to access an acceleration-enabled bucket over IPv6. Amazon S3 dual-stack endpoints support requests to S3 buckets over IPv6 and IPv4. The Transfer Acceleration dual-stack endpoint only uses the virtual hosted-style type of endpoint name. For more information, see Getting Started Making Requests over IPv6 and Using Amazon S3 Dual-Stack Endpoints. You can use the Amazon S3 Transfer Acceleration Speed Comparison tool to compare accelerated and non-accelerated upload speeds across Amazon S3 regions. The Speed Comparison tool uses multipart uploads to transfer a file from your browser to various Amazon S3 regions with and without using Transfer Acceleration.

It is copied from this article https://docs.aws.amazon.com/AmazonS3/latest/dev/transfer-acceleration.html

http://s3-accelerate-speedtest.s3-accelerate.amazonaws.com/en/accelerate-speed-comparsion.html

like image 44
Jin Thakur Avatar answered Oct 02 '22 19:10

Jin Thakur