amplify-android: Amplify.Storage.uploadFile fails with large files

File uploading operation fails while uploading a video file. 4 out of 10 time the video uploading fails with the below exception. The internet connection is good as well. File upload operation tested with both wifi/mobile networks , results in same error.

The same file upload operation with same network works fine in the Amplify IOS SDK.

Amplify version used 1.6.8

Code used to call file upload

Amplify.Storage.uploadFile(
    UUID.randomUUID().toString(),
    file,
    StorageUploadFileOptions.builder()
        .accessLevel(StorageAccessLevel.PUBLIC)
        .contentType(Mimetypes.getInstance().getMimetype(file))
        .build(),
    { progress -> },
    { success -> },
    { error -> }
)

W/System.err: StorageException{message=Storage upload operation was interrupted., cause=null, recoverySuggestion=Please verify that you have a stable internet connection.} W/System.err: StorageException{message=Something went wrong with your AWS S3 Storage upload file operation, cause=com.amazonaws.AmazonClientException: Unable to execute HTTP request: failed to connect to development-uplift-remote-resources.s3.us-west-2.amazonaws.com/52.218.249.201 (port 443) from /192.168.0.101 (port 40772) after 15000ms, recoverySuggestion=See attached exception for more information and suggestions} 2021-01-11 13:39:33.760 24912-24912/com.uplift.coach.dev W/System.err: at com.amplifyframework.storage.s3.operation.AWSS3StorageUploadFileOperation$UploadTransferListener.onError(AWSS3StorageUploadFileOperation.java:207) Caused by: java.net.SocketTimeoutException: failed to connect to development-uplift-remote-resources.s3.us-west-2.amazonaws.com/52.218.249.201 (port 443) from /192.168.0.101 (port 40772) after 15000ms

Devices tested with

One plus 6T - OS version 10 Galaxy M11 - OS version 10

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 3
  • Comments: 16 (5 by maintainers)

Most upvoted comments

Hi Guys,

Not sure if its a permanent fix but i was able to reduce the failure rate by increasing the socket timeout or even setting it to 0(which is infinite). Please do some trial and error to come up with suitable timeout.

val plugin = Amplify.Storage.getPlugin("awsS3StoragePlugin") as AWSS3StoragePlugin
            val client = plugin.escapeHatch
            client.setConfiguration(ClientConfiguration().apply {
                socketTimeout = 60 * 1000 
            })

Disclaimer: This is not a solution, its just a fix for people who are using this is production as setConfiguration(ClientConfiguration clientConfiguration) is deprecated.

@raphkim Could you share a little bit how this issue was fixed ?

Hi, the latest version of Amplify (1.17.4 as of writing) contains fix to increase the stability of large file uploads. Please let us know if the issue persists after updating the library.

@raphkim : This is very critical. Sorry, but super amazed at how lightly this issue is been taken. Any path or estimate with be greatly appreciated.