1

New to Amazon S3 usage.I get the following error when trying to access the file from Amazon S3 using a simple java method.

2016-08-23 09:46:48 INFO  request:450 - Received successful response:200, AWS Request ID: F5EA01DB74D0D0F5
Caught an AmazonClientException, which means the client encountered an   
internal error while trying to communicate with S3, such as not being 
able to access the network.
Error Message: Unable to store object contents to disk: Read timed out

The exact lines of code worked yesterday.I was able to download 100% of 5GB file in 12 min. Today I'm in a better connected environment but only 2% or 3% of the file is downloaded and then the program fails.

Code that I'm using to download.

s3Client.getObject(new GetObjectRequest("mybucket", file.getKey()), localFile); 
Vinodh Thiagarajan
  • 758
  • 3
  • 9
  • 19

1 Answers1

4

You need to set the connection timeout and the socket timeout in your client configuration.

Click here for a reference article

Here is an excerpt from the article:

Several HTTP transport options can be configured through the com.amazonaws.ClientConfiguration object. Default values will suffice for the majority of users, but users who want more control can configure: 
Socket timeout
Connection timeout
Maximum retry attempts for retry-able errors
Maximum open HTTP connections

Here is an example on how to do it:

Downloading files >3Gb from S3 fails with "SocketTimeoutException: Read timed out"

Community
  • 1
  • 1
Gufran
  • 41
  • 3
  • What is a recommended setting for this? Java DOC says `A value of 0 means infinity, and isn't recommended`, so how to avoid this error? – Beto Neto May 07 '18 at 13:22
  • The default value currently is `50 seconds`, can this be a solution: https://stackoverflow.com/questions/40500888/aws-swf-decider-java-net-sockettimeoutexception-read-timed-out-when-polling/40501614#40501614 – Beto Neto May 07 '18 at 13:43