Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry strategy for TransferUtility #576

Closed
CodingInfinite opened this issue Nov 15, 2018 · 9 comments
Closed

Retry strategy for TransferUtility #576

CodingInfinite opened this issue Nov 15, 2018 · 9 comments
Assignees
Labels
feature-request Request a new feature s3 Issues with the AWS Android SDK for Simple Storage Service (S3).

Comments

@CodingInfinite
Copy link

CodingInfinite commented Nov 15, 2018

AmazonS3Client is not using my ClientConfiguartion. I'm uploading some songs to S3 and on slow Internet my songs are not uploded and failed several times. Although in my ClientConfiguration I have 0 maxRetry but don't know why it retries multiple time.

I'm using AWS S3 SDK and dependency version is 2.8.+

Device Information (please complete the following information):

  • Infinix S3
  • Android Version: [26]
  • Specific to simulators:

My Code For ClientConfiguration

    private fun getClientConfiguration(): ClientConfiguration {
        val clientConfiguration = ClientConfiguration()
        clientConfiguration.withMaxErrorRetry(0)
            .withConnectionTimeout(5000)
            .withSocketTimeout(10000)
        return clientConfiguration
    }

And the AmazonS3Client

private fun getS3Client(): AmazonS3Client  {

        if (sS3Client == null) {
            sS3Client = AmazonS3Client(basicAwsCredentials(), getClientConfiguration()).apply {
                setS3ClientOptions(
                    S3ClientOptions
                        .builder()
                        .setAccelerateModeEnabled(true)
                        .build()
                )
                setBucketAccelerateConfiguration(
                    Constants.BUCKET_NAME,
                    BucketAccelerateConfiguration(BucketAccelerateStatus.Enabled)
                )
            }
        }
        return sS3Client as AmazonS3Client
    } 
@mutablealligator mutablealligator self-assigned this Nov 15, 2018
@mutablealligator mutablealligator added the s3 Issues with the AWS Android SDK for Simple Storage Service (S3). label Nov 15, 2018
@mutablealligator mutablealligator changed the title ClientConfiguration Not Working ClientConfiguration not respected by AmazonS3Client Nov 15, 2018
@CodingInfinite
Copy link
Author

Any update on this issue..?

@mutablealligator
Copy link
Contributor

@CodingInfinite Sorry for the delayed response. What exception were you getting for your upload and how many times was the upload retried? Can you post the exception message and stacktrace?

@frankmuellr frankmuellr added the pending-community-response Issue is pending response from the issue requestor label Nov 19, 2018
@CodingInfinite
Copy link
Author

The application retried three times when the error occurs. Also, one more thing I got during upload when I cancel the upload after that when I start again the uploading it never uploads until I restart my application.

That's how I cancel the upload.

transferUtility?.cancelAllWithType(TransferType.UPLOAD)

@mutablealligator
Copy link
Contributor

To cancel the upload, you can do transferUtility.cancel(transferObserver.getId());

@CodingInfinite
Copy link
Author

Yes, first I do the same what you suggested but canceling the upload with id cancels successfully but never able to upload again until I restart my application.

In my Activity onCreate method, I start the TransferUtilty service.

startService(Intent(context, TransferService::class.java))

I have this scenario where I need to upload multiple songs to Amazon S3 and below is my method for upload songs.

fun uploadParty(uploadPartyModel: UploadPartyModel) {
      launch(context = coroutineContext) {
            try {
                val folderName = amazonS3Utility.getFolderName(uploadPartyModel.partyTitle)
                for (musicModel in uploadPartyModel.uploadMusicModels) {
                    val file = musicModel.file
                    launch {
                        val transferObserver =
                            transferUtility.upload(AmazonS3Utility.BUCKET_NAME, folderName.plus(file?.name), file)
                        transferObserver.setTransferListener(transferListener)
                    }
                }
            } catch (e: java.lang.Exception) {
                _songsUploader.postValue(UploadState.Failed)
            }
        }
    }

That's how I cancel the upload.

fun cancelUploads() {
           job.cancel()
           transferUtility?.cancelAllWithType(TransferType.UPLOAD)
  }

The above cancelUpload method successfully cancel all the upload songs but after cancelation when I again call my uploadParty method it never starts uploading.

@CodingInfinite
Copy link
Author

Any feedback on this....?

@frankmuellr frankmuellr added question General question and removed pending-community-response Issue is pending response from the issue requestor labels Dec 3, 2018
@mutablealligator
Copy link
Contributor

@CodingInfinite Sorry for the delayed response. Once the upload is cancelled, you cannot resume it again. You need to start a new upload. However if you want to resume an upload, you need to pause it by calling transferUtility.pause.

TransferUtility doe not retry the failed transfers. I will file a feature request to the team for the retry functionality in TransferUtility. The retries you set in ClientConfiguration is only honored at the layer where the HTTP request is being sent to S3. If the HTTP request resulted in an error which is retryable, then the retries count and policy set in ClientConfiguration will be honored. However if the error is at the TransferUtility layer, then it's a missing feature.

@mutablealligator mutablealligator added the pending-community-response Issue is pending response from the issue requestor label Dec 27, 2018
@frankmuellr frankmuellr added feature-request Request a new feature and removed question General question pending-community-response Issue is pending response from the issue requestor labels Dec 28, 2018
@mutablealligator mutablealligator changed the title ClientConfiguration not respected by AmazonS3Client ClientConfiguration#Retry not respected by AmazonS3Client Feb 11, 2019
@mutablealligator mutablealligator changed the title ClientConfiguration#Retry not respected by AmazonS3Client Retry strategy for TransferUtility Apr 25, 2019
@mutablealligator
Copy link
Contributor

Tracking this issue in #616. So closing this issue.

@elvalelucho
Copy link

honorMaxErrorRetryInClientConfig must be configurated TRUE on RetryPolicy

@github-actions github-actions bot added the pending-maintainer-response Issue is pending response from an Amplify team member label Dec 2, 2024
@mattcreaser mattcreaser removed the pending-maintainer-response Issue is pending response from an Amplify team member label Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request a new feature s3 Issues with the AWS Android SDK for Simple Storage Service (S3).
Projects
None yet
Development

No branches or pull requests

5 participants