I'm currently using the AWS SDK for Java v2 (specifically v2.17.1) and the S3AsyncClient::getObject method.
final GetObjectRequest getObjectRequest = GetObjectRequest.builder()
.bucket("my bucket")
.key("some key")
.overrideConfiguration(AwsRequestOverrideConfiguration.builder()
.apiCallAttemptTimeout(Duration.ofSeconds(1))
.build())
.build();
return s3AsyncClient
.getObject(getObjectRequest, AsyncResponseTransformer.toBytes())
.thenAppply(/* snipped for brevity */);
This mostly works fine, but occasionally I get bursts of these errors:
software.amazon.awssdk.core.exception.ApiCallAttemptTimeoutException: HTTP request execution did not complete before the specified timeout configuration: 1000 millis
I currently have the following configuration on the builder that creates that s3AsyncClient
above:
S3AsyncClient.builder()
// other options snipped for brevity
.overrideConfiguration(ClientOverrideConfiguration.builder()
.retryPolicy(RetryPolicy.builder()
.numRetries(2)
.build())
.build())
.build()
Is there a way to make it so that different apiCallAttemptTimeout
values are used depending on how many retry attempts have been made? In other words, how do I get exponential retry timeouts working?
I'm aware a newer version of the SDK includes a new ADAPTIVE
RetryMode option, but my understanding is that this only applies when you're being rate limited by AWS. I've also seen parts of the S3 code that can exponentially delay the time between retries, but not the timeout for each retry.
Any help is appreciated - thank you!