Carrierwave + s3 + fog (Excon::Errors::SocketError)
Asked Answered
O

2

8

I'm currently getting the following error: Excon::Errors::SocketError - Broken pipe (Errno::EPIPE) when uploading images bigger than about 150kb. Images under 150kb work correctly. Research indicates that others have also experienced this problem but I'm yet to find a solution.

Error message

Excon::Errors::SocketError at /photos

Message Broken pipe (Errno::EPIPE)
File    /Users/thmsmxwll/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/openssl/buffering.rb
Line    375

image_uploader.rb

class ImageUploader < CarrierWave::Uploader::Base
  include CarrierWave::RMagick

  storage :fog

  include CarrierWave::MimeTypes
  process :set_content_type

  def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end

  version :large do
    process :resize_to_limit => [800, 600]
  end
end

carrierwave.rb

CarrierWave.configure do |config|
  config.fog_credentials = {
    :provider               => 'AWS',
    aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],                        
    aws_secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
    :region                 => 'us-east-1'
  }
  config.fog_directory  = 'abcd'                   
  config.fog_public     = true                                  
  config.fog_attributes = {'Cache-Control'=>'max-age=315576000'}
end
Oscillogram answered 30/12, 2012 at 11:10 Comment(3)
I think we are dealing with the same problem. Have you found any solution against this issue? ThxWebworm
I came up against this error a few days ago and it turned out that my fog_directory was incorrect (it's a terribly general error for something so specific). It may be worth checking the bucket name is correct and that the permissions are set correctly.Robber
Have triple checked my bucket name and that the permissions are correct still getting the same error.Oscillogram
D
9

For me, the solution required me to recreate the bucket in the US-Standard region. Originally, the bucket was in the Oregon region and while I wasn't specifying a region in my carrierwave settings, I could not get an upload to complete, even with very small files.

Devitt answered 12/9, 2013 at 3:20 Comment(2)
Hi had the same problem (couldn't even upload small files) and your solution (switching to US-Standard region) also worked for me.Houdan
Worked for me as well. It seems US-Standard doesn't require us to specify a region. An alternative solution is to specify the right region for your bucket: bucketexplorer.com/documentation/…Cento
W
1

I'm having the same issue, i noticed that only happend when i upload big files (400kb), with a smaller (100kb) it works fine.

Will answered 20/2, 2013 at 14:54 Comment(5)
I found that I couldn't upload anything bigger than 150kb - still haven't found a solution to the problem other than lowering the image file size.Oscillogram
The problem was in my bucket region. When i created the bucket it was pointing to a different location than was specified in the initializer/carrierwave.rb file. After i corrected my region everything worked!.Will
I've double checked this... I'll triple check and see if it resolves my issue. Thanks.Oscillogram
I can confirm that it is a settings issue with region. I was having the same issue where smaller files would be uploaded to s3, but larger files would lead to broken pipe error. I logged into my aws s3 console and observed us-west-2 so I added it to my carrierwave config and large file uploads work now.Shimkus
Although when I converted my rails project over to jruby, this was happening again. And no amount of changing the region code was helping. So I read somewhere else that changing the order of some gems helped. I tried that and it seemed to workShimkus

© 2022 - 2024 — McMap. All rights reserved.