2016-08-23 372 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"