任何人都在寻找不存在的键时,遇到了AWS-S3超时问题? S3Object.exist?和S3Object.request(:头,..) [英] Anyone else experiencing aws-s3 timeout problems when looking for nonexistant keys? S3Object.exist? and S3Object.request(:head, ..)

查看:826
本文介绍了任何人都在寻找不存在的键时,遇到了AWS-S3超时问题? S3Object.exist?和S3Object.request(:头,..)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人有问题,AWS-S3的S3Object.exists?还是S3Object.request(:头,...)超时时,通过按键不存在吗? (我运行AWS-S3 0.6.2,红宝石1.9.2)。如预期使用S3Object.find('thenonexistantkey',桶)提出了NoSuchKey异常。这是亚马逊的身边问题?

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的宝石不设置超时时间为合理值

aws-s3 gem does not set the timeout to reasonable values

您可以通过的monkeypatching其做create_connection 方法

You can do it by monkeypatching its create_connection method

创建一个文件配置/初始化/ 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

这篇关于任何人都在寻找不存在的键时,遇到了AWS-S3超时问题? S3Object.exist?和S3Object.request(:头,..)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆