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
  • I think we are dealing with the same problem. Have you found any solution against this issue? Thx – Bachet Jan 25 '13 at 13:01
  • 1
    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. – Wakeuphate Feb 12 '13 at 16:10
  • Have triple checked my bucket name and that the permissions are correct still getting the same error. –  Feb 13 '13 at 03:59

2 Answers2

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.

Alex
  • 398
  • 3
  • 7
  • Hi had the same problem (couldn't even upload small files) and your solution (switching to US-Standard region) also worked for me. – Daan Nov 04 '14 at 21:17
  • 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: http://www.bucketexplorer.com/documentation/amazon-s3--amazon-s3-buckets-and-regions.html – rebagliatte Dec 23 '14 at 13:24
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.

Marcio Klepacz
  • 617
  • 6
  • 19
  • 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. –  Feb 21 '13 at 01:35
  • 5
    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!. – Marcio Klepacz Feb 26 '13 at 18:50
  • I've double checked this... I'll triple check and see if it resolves my issue. Thanks. –  Feb 27 '13 at 01:18
  • 1
    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. – Homan Jun 20 '13 at 04:46
  • 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 work – Homan Jun 30 '13 at 18:19