2016-08-23 94 views
0

Amazon S3的新用法。嘗試使用簡單的java方法從Amazon S3訪問文件時出現以下錯誤。Amazon S3文件讀取超時。嘗試使用JAVA下載文件

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 

確切的代碼行昨天工作。我能夠在12分鐘內下載100GB的5GB文件。今天我處在一個更好的連接環境中,但只有2%或3%的文件被下載,然後程序失敗。

我正在使用的代碼下載。

s3Client.getObject(new GetObjectRequest("mybucket", file.getKey()), localFile); 

回答

0

您需要在客戶端配置中設置連接超時和套接字超時。

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 

這裏是如何做到這一點的例子:

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