gpt4 book ai didi

ruby-on-rails - Errno::ECONNREFUSED: 连接被拒绝 - connect(2) for "bucketname.s3-eu-west-1.amazonaws.com"

转载 作者:太空宇宙 更新时间:2023-11-03 16:46:56 24 4
gpt4 key购买 nike

我有一个默认文件,在注册新帐户后会发送到亚马逊存储桶。那奏效了。但是突然间,在不更改任何代码的情况下,我所有使用此方法的测试都失败并显示错误:

Errno::ECONNREFUSED: Connection refused - connect(2) for "(bucketname).s3-eu-west-1.amazonaws.com" port 443

是什么导致这个错误突然出现?测试错误都指向下面方法中的obj.upload_file(drawingfile)

发送文件的模型方法没有改变,是:

def self.upload_empty_drawing(id)  # In the S3 bucket's I've granted access to my heroku domain as well as to https://<name>.c9.io (I'm programming in Cloud9, an IDE solution)
s3 = Aws::S3::Resource.new(
credentials: Aws::Credentials.new(
Rails.application.secrets.S3_ACCESS_KEY,
Rails.application.secrets.S3_SECRET_KEY),
region: Rails.application.secrets.AWS_REGION
)
drawingfile = 'app/assets/emptyexample.xml'
filename = "example/#{id}/example-#{id}.xml"
obj = s3.bucket(Rails.application.secrets.S3_BUCKET_EXAMPLES).object(filename)
obj.upload_file(drawingfile)
Drawing.create!(organization_id: id, example_file: obj.public_url)
end

更新:我认为除了模型方法中的错误之外,可能还有其他原因。因为:

  • 我的生产站点似乎也受到了影响。我尝试在我的生产网站上注册,但收到错误消息很抱歉,出了点问题
  • 在终端中输入 heroku logs --tail(正如我提到的,我使用 Cloud9 IDE),产生了错误 Unable to connect to api.heroku.com
  • 如果我尝试在开发服务器上注册,在注册时,我会遇到与我在运行测试时提到/遇到的相同的connection refused错误。
  • 在终端中输入 heroku config,产生错误 Unable to connect to Heroku API, please check internet connectivity and try again

不确定发生了什么......!?对于如何找出问题的任何想法,我们将不胜感激。

最佳答案

我遇到了与权限相关的类似问题,所以我更新了我的代码

`......image.rb`............

has_attached_file :avatar,
:styles =>
{
:medium => "x300",
:small => "150x150>",
:thumb => "90x90>",
},
:storage => :s3,
:s3_permissions => :private,
:s3_credentials => S3_CREDENTIALS

.....config/initializers/paperclip.rb...............

S3_CREDENTIALS = Rails.root.join("config/s3.yml")
Paperclip::Attachment.default_options[:url] = ':s3_domain_url'
Paperclip::Attachment.default_options[:path] = '/:class/:id/:style/:filename'

.....config/s3.yml....................
development:
bucket: mybucketname
access_key_id: xxxxxxxxxxxxxxxxxxxxx
secret_access_key: xxxxxxxxxxxxxxxx+xxxxxxxxx

关于ruby-on-rails - Errno::ECONNREFUSED: 连接被拒绝 - connect(2) for "bucketname.s3-eu-west-1.amazonaws.com",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31313991/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com