Anyone else experiencing aws-s3 timeout problems when looking for nonexistant keys? S3Object.exist? and S3Object.request(:head, ..)
Has anyone been having problems with aws-s3's S3Object.exists?, or S3Object.request(:head, ...) timing out when passed keys which do not exist? (I'm running aws-s3 0.开发者_运维技巧6.2, ruby 1.9.2). Using S3Object.find('thenonexistantkey', bucket) raises a NoSuchKey exception as expected. Is this an issue on amazon's side?
aws-s3 gem does not set the timeout to reasonable values
You can do it by monkeypatching its create_connection
method
Create a file config/initializers/aws_s3_connection_monkey_patch.rb
:
# Sets the timeouts to appropriate values for S3
module AWS
module S3
class Connection #:nodoc:
private
def create_connection_with_timeout_settings
http = create_connection_without_timeout_settings
http.open_timeout = 1
http.read_timeout = 5
http
end
alias_method_chain :create_connection, :timeout_settings
end
end
end
精彩评论