开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜