aws java sdk ClientExecutionTimeoutException

3k Views Asked by At

We are getting ClientExecutionTimeoutException when using below values

 ClientConfiguration config = new ClientConfiguration();
 config.setClientExecutionTimeout(100);
 config.setRequestTimeout(100);

This is in health check call which checks if bucket exists

amazonS3.doesBucketExistV2(bucketName);

Has anyone faced similar issue and what could be solution for this. I checked in POC and if I set it to 400, error disappears. Using aws-java-sdk-s3 v 1.11 and java 8.

1

There are 1 best solutions below

0
On BEST ANSWER

Since the timeout is set in milliseconds, you have set a very low execution and request timeout.

I would recommend you to:

  • Set it to 400 ms.
  • Test how much time it takes for your command to execute:
long startTime = System.currentTimeMillis();
amazonS3.doesBucketExistV2(bucketName);
long endTime = System.currentTimeMillis();
long timeElapsed = endTime - startTime;
System.out.println("Execution time in milliseconds: " + timeElapsed);

  • If the time elapsed is above 100 ms, then your code fails for 100 ms because it is supposed to be.
  • Set your timeout according to your needs and you are done.