I have a default file that upon signup of a new account, gets send to an amazon bucket. That worked. But suddenly, without changing any code, all my tests that use this method, fail with the error:
我有一个默认文件,在注册新帐户后,会发送到亚马逊桶。那很有效。但突然间,在不更改任何代码的情况下,我使用此方法的所有测试都失败并显示错误:
Errno::ECONNREFUSED: Connection refused - connect(2) for "(bucketname).s3-eu-west-1.amazonaws.com" port 443
Errno :: ECONNREFUSED:连接被拒绝 - 连接(2)为“(bucketname).s3-eu-west-1.amazonaws.com”端口443
What could have caused this error to show up so suddenly? The test errors all point to obj.upload_file(drawingfile)
in the method below.
什么可能导致这个错误突然出现?测试错误都指向下面方法中的obj.upload_file(drawingfile)。
The model method that sends the file has not been changed and is:
发送文件的模型方法尚未更改,并且是:
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
Update: I think there may be something else going on than an error in the model method. Because:
更新:我认为可能还有其他事情发生,而不是模型方法中的错误。因为:
- Also my production site seems affected. I tried to sign up on my production site and got the error
We're sorry, but something went wrong
. - Entering
heroku logs --tail
in the terminal (as I mentioned, I use Cloud9 IDE), produced the errorUnable to connect to api.heroku.com
. - If I try to sign up on the development server, upon sign up, I get the same
connection refused
error that I mentioned/get when running my tests. - Entering
heroku config
in the terminal, produces the errorUnable to connect to Heroku API, please check internet connectivity and try again
.
我的生产网站也受到影响。我试图在我的生产网站上注册并收到错误我们很抱歉,但出了点问题。
在终端输入heroku日志--tail(如我所提到的,我使用Cloud9 IDE),产生错误无法连接到api.heroku.com。
如果我尝试在开发服务器上注册,注册后,我会在运行测试时得到同样的连接拒绝错误。
在终端中输入heroku配置,产生错误无法连接到Heroku API,请检查互联网连接,然后重试。
Not sure what is going on ... !? Any ideas how to find out the problems, are appreciated.
不知道发生了什么......!?如何找出问题的任何想法,表示赞赏。
2 个解决方案
#1
0
i had this similar problem which was related to permissons,so i updated the code in my
我有这个类似的问题与permissons有关,所以我更新了我的代码
`......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
#2
0
I've been in touch with the IDE that I use for writing my code. They were so kind to reset/reboot my account or something (not sure what they did exactly but I had "Reconnecting" on my screen for several minutes). After this, all the problems were gone. So the cause seems to have been configuration settings on the side of the IDE.
我一直在使用我用来编写代码的IDE。他们非常友好地重置/重新启动我的帐户或其他东西(不确定他们做了什么,但我在屏幕上“重新连接”几分钟)。在此之后,所有问题都消失了。因此,原因似乎是IDE侧面的配置设置。
(P.S. The production side problem had a different cause: although I had set the key for a secret variable, in secrets.yml
I had not yet defined using it in production (only in development and test))
(P.S.生产方面的问题有不同的原因:虽然我设置了一个秘密变量的密钥,但在secretts.yml中我还没有定义在生产中使用它(仅在开发和测试中))