amplify-android icon indicating copy to clipboard operation
amplify-android copied to clipboard

uploadInputStream idle after restoring internet access

Open pcanas opened this issue 3 years ago • 2 comments

Before opening, please confirm:

Language and Async Model

Not applicable

Amplify Categories

Storage

Gradle script dependencies

implementation 'com.amplifyframework:core:1.28.1'
implementation 'com.amplifyframework:aws-api:1.28.1'
implementation 'com.amplifyframework:aws-auth-cognito:1.28.1'
implementation 'com.amplifyframework:aws-datastore:1.28.1'
implementation 'com.amplifyframework:aws-storage-s3:1.28.1'

Environment information

------------------------------------------------------------
Gradle 7.3.3
------------------------------------------------------------

Build time:   2021-12-22 12:37:54 UTC
Revision:     6f556c80f945dc54b50e0be633da6c62dbe8dc71

Kotlin:       1.5.31
Groovy:       3.0.9
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          1.8.0_331 (Oracle Corporation 25.331-b09)
OS:           Mac OS X 12.3.1 x86_64

Please include any relevant guides or documentation you're referencing

https://docs.amplify.aws/lib/storage/upload/q/platform/android/#upload-files

Describe the bug

I would like to run the function uploadInputStream with no internet access so that it starts the upload as soon as internet connectivity is restored.

Most of the times this works fine, and the upload starts right when reconnecting, but sometimes the upload does not happen, and no value is returned either as a success or error.

Is there anyway I can handle these scenarios?

Reproduction steps (if applicable)

  1. Disconnect from WiFi and data (no internet access).
  2. Run uploadInputStream
  3. Re-connect. Most of the times it will commence the upload right away, but sometimes the function stays idle (neither success nor error is returned).

Code Snippet

// This way of setting a socket timeout is deprecated, we need to find another alternative
val awsS3StoragePlugin = Amplify.Storage.getPlugin("awsS3StoragePlugin") as AWSS3StoragePlugin
val client = awsS3StoragePlugin.escapeHatch
client.setConfiguration(ClientConfiguration().apply {
    socketTimeout = 0
})

...

Amplify.Storage.uploadInputStream(key, stream,
    { onSuccess() },
    {
      Log.e("MyAmplifyApp", it.toString())
    }
)

Log output

No response

amplifyconfiguration.json

No response

GraphQL Schema

// Put your schema below this line


Additional information and screenshots

No response

pcanas avatar Aug 31 '22 14:08 pcanas

@banji180 any updates on this?

pcanas avatar Sep 05 '22 06:09 pcanas

Hey @banji180 sorry to bug you again but I was wondering if you've had the time to check this issue. Thanks!

pcanas avatar Sep 13 '22 10:09 pcanas

@sdhuka any updates? thanks!

pcanas avatar Oct 19 '22 07:10 pcanas

@pcanas I will try to repro this on my end, but it would be helpful if you could share the logs after the device goes online to investigate why the upload is not resumed.

sdhuka avatar Oct 21 '22 16:10 sdhuka

We tried to repro and could not repro on our end. It would be helpful if you could share the logs for us to investigate further.

sdhuka avatar Nov 07 '22 17:11 sdhuka

@pcanas Closing this issue due to lack of information to diagnose the issue. We also recently re-architected the storage plugin implementation in Amplify 2.0 using the workmanager library which responds better to network changes, we highly recommend you to upgrade to 2.0 in case this issue persists.

sdhuka avatar Nov 22 '22 14:11 sdhuka

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

github-actions[bot] avatar Nov 22 '22 14:11 github-actions[bot]