【问题标题】:Amazon S3 File Read Timeout. Trying to download a file using JAVAAmazon S3 文件读取超时。尝试使用 JAVA 下载文件
【发布时间】:2016-08-23 14:53:50
【问题描述】:

刚开始使用 Amazon S3。尝试使用简单的 java 方法从 Amazon S3 访问文件时出现以下错误。

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 分钟内下载 100% 的 5GB 文件。今天我在一个更好的连接环境中,但只下载了 2% 或 3% 的文件,然后程序就失败了。

我用来下载的代码。

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

【问题讨论】:

    标签: amazon-s3


    【解决方案1】:

    您需要在客户端配置中设置连接超时和套接字超时。

    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"

    【讨论】:

    • 对此的推荐设置是什么? Java DOC 说A value of 0 means infinity, and isn't recommended,那么如何避免这个错误呢?
    • 目前的默认值是50 seconds,可以这样解决吗:stackoverflow.com/questions/40500888/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-10-10
    • 2012-08-29
    • 2013-05-08
    • 1970-01-01
    • 2016-09-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多