incompatible Net::HTTP monkey-path

27 views
Skip to first unread message

hunkybill

unread,
Jul 22, 2008, 6:11:19 PM7/22/08
to Paperclip Plugin
Hi,

I was using RightAws in conjunction with file_column to process files
and thumbail them.. using S3 for storage when I decided to try
Paperclip out. The bonus for me would be to have all my thumbs stored
in S3.

I changed my model to use Paperclip, and tried this simple
configuration:

has_attached_file :image,

:styles => {
:thumb => "50x50",
:preview => "240x240",
:large => "480x480"
},
:storage => :s3,
:s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
:path => ":attachment/:id/:style.:extension",
:bucket => 'my-foo-bucket'

My image column is a string, and worked great with file_column. The
one twist is that I am not doing file uploads, but instead, I am using
S3 to download files into my Rails tmp/ directory, where I can extract
their actual mimetype and ImageMagick process them

I am getting the Net::HTTP error in my rake task. I have only the
require 'right-aws' in my rake task...

I installed the Paperclip plugin in my vendor/plugins/git
directory...

It seems this error occurs when I do the following:

m = MyModel.find(:first)
real_file=File.open(fn)
m.image = real_file
m.save

So, upon trying to save the file I open (and it is a valid, open
file)... things bomb...

Do I need to do something else here?

I would LOVE to get this nifty little combination of S3+Paperclip
using the RightAws library working...

Any tips please on where to look for problems!!!

Thanks

Dave

hunkybill

unread,
Jul 22, 2008, 11:12:51 PM7/22/08
to Paperclip Plugin
After a bit more digging.. Paperclip works fine in file mode.. minus
any S3 connections... with them.. I get this when I assign my file to
the instance.attachment... in my case media.image = file So, it seems
Paperclip is fine for the most part, and the problem is now
interfacing Paperclip with RightAws? I am using latest of each...
right_aws v1.7.3 with right_http_connection v1.2.3, and paperclip
v2.1.2



incompatible Net::HTTP monkey-patch
/usr/lib/ruby/gems/1.8/gems/right_http_connection-1.2.3/lib/
right_http_connection.rb:402:in `request'
/usr/lib/ruby/gems/1.8/gems/right_http_connection-1.2.3/lib/
right_http_connection.rb:330:in `loop'
/usr/lib/ruby/gems/1.8/gems/right_http_connection-1.2.3/lib/
right_http_connection.rb:330:in `request'
/usr/lib/ruby/gems/1.8/gems/right_aws-1.7.3/lib/awsbase/
right_awsbase.rb:245:in `request_info_impl'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/lib/ruby/gems/1.8/gems/right_aws-1.7.3/lib/awsbase/
benchmark_fix.rb:30:in `add!'
/usr/lib/ruby/gems/1.8/gems/right_aws-1.7.3/lib/awsbase/
right_awsbase.rb:245:in `request_info_impl'
/usr/lib/ruby/gems/1.8/gems/right_aws-1.7.3/lib/s3/
right_s3_interface.rb:161:in `request_info'
/usr/lib/ruby/gems/1.8/gems/right_aws-1.7.3/lib/s3/
right_s3_interface.rb:363:in `put'
/usr/lib/ruby/gems/1.8/gems/right_aws-1.7.3/lib/s3/right_s3.rb:451:in
`put'
/usr/lib/ruby/gems/1.8/gems/paperclip-2.1.2/lib/paperclip/storage.rb:
95:in `flush_writes'
/usr/lib/ruby/gems/1.8/gems/paperclip-2.1.2/lib/paperclip/storage.rb:
91:in `each'
/usr/lib/ruby/gems/1.8/gems/paperclip-2.1.2/lib/paperclip/storage.rb:
91:in `flush_writes'
/usr/lib/ruby/gems/1.8/gems/paperclip-2.1.2/lib/paperclip/
attachment.rb:114:in `save'
/usr/lib/ruby/gems/1.8/gems/paperclip-2.1.2/lib/paperclip.rb:226:in
`send'
/usr/lib/ruby/gems/1.8/gems/paperclip-2.1.2/lib/paperclip.rb:226:in
`save_attached_files'
/usr/lib/ruby/gems/1.8/gems/paperclip-2.1.2/lib/paperclip.rb:220:in
`each_attachment'
/usr/lib/ruby/gems/1.8/gems/paperclip-2.1.2/lib/paperclip.rb:219:in
`each'
/usr/lib/ruby/gems/1.8/gems/paperclip-2.1.2/lib/paperclip.rb:219:in
`each_attachment'
/usr/lib/ruby/gems/1.8/gems/paperclip-2.1.2/lib/paperclip.rb:225:in
`save_attached_files'

Jonathan Yurek

unread,
Jul 23, 2008, 10:01:37 AM7/23/08
to papercli...@googlegroups.com
Hmm, I haven't had any problems with RightAWS, but I currently have
1.7.1/1.2.1, so maybe something changed. I'll look into this and get
back to you.

One other thing, what version of Ruby do you have? Are you trying this
with 1.8.7?

--
Jonathan Yurek
thoughtbot, inc.
jyu...@thoughtbot.com
617.482.1300 x114


hunkybill

unread,
Jul 23, 2008, 10:19:45 AM7/23/08
to Paperclip Plugin
Hi,



On Jul 23, 10:01 am, Jonathan Yurek <jyu...@thoughtbot.com> wrote:
> Hmm, I haven't had any problems with RightAWS, but I currently have  
> 1.7.1/1.2.1, so maybe something changed. I'll look into this and get  
> back to you.
>

Xtra cool... please do.... this is reaaly key to my project...



> One other thing, what version of Ruby do you have? Are you trying this  
> with 1.8.7?
>

1.8.6 2007-09-24 patchlevel 111

Thanks

hunkybill

unread,
Jul 23, 2008, 12:40:15 PM7/23/08
to Paperclip Plugin
Hi,

In checking out the code for right_http_connection.rb, the exception
process handling the paperclip transfer to S3 is:

rescue Exception => e # See comment at bottom for the list of errors
seen...
@http = nil
# if ctrl+c is pressed - we have to reraise exception to
terminate proggy
if e.is_a?(Interrupt) && !( e.is_a?(Errno::ETIMEDOUT) ||
e.is_a?(Timeout::Error))
@logger.debug( "#{err_header} request to server #{@server}
interrupted by ctrl-c")
raise
elsif e.is_a?(ArgumentError) && e.message.include?('wrong
number of arguments (5 for 4)')
# seems our net_fix patch was overriden...
exception = get_param(:exception) || RuntimeError
raise exception.new('incompatible Net::HTTP monkey-patch')
end
# oops - we got a banana: log it
error_add(e.message)
@logger.warn("#{err_header} request failure count:
#{error_count}, exception: #{e.inspect}")

# We will be retrying the request, so reset the file pointer
reset_fileptr_offset(request, mypos)

end

So it seems the wrong number of arguments error is being thrown. Is
that making any sense? Is paperclip sending too many arguments to the
right_http_connection?

Thanks

Jonathan Yurek

unread,
Jul 23, 2008, 4:54:33 PM7/23/08
to papercli...@googlegroups.com
Hmm, this is starting to sound like an issue someone else on the list
had. What other plugins and gems are you using with this project?

hunkybill

unread,
Jul 23, 2008, 5:17:28 PM7/23/08
to Paperclip Plugin
My rake task requires 'right_aws' (as does paperclip)

For my Rails project the current list of plugins is:
active_rbac
acts_as_tree
acts_as_taggable_on
file_column
paperclip
rspec


I know someone mentioned something called Beast being in conflict, I
am not using that.

I was and am 100% able to use RigthAws library to do a lot of back and
forth with S3. It is only with the introduction of Paperclip that this
problem manifests itself, right when Paperclip tries to flush_write
the file to S3. ie) with no Paperclip, I can transfer files to S3 no
problem, read them back, etc... Letting Paperclip try and do that...
poof...



Is this getting closer???

Thanks!

Dave

voodoo...@gmail.com

unread,
Jul 25, 2008, 11:32:53 AM7/25/08
to Paperclip Plugin
I have tracked this issue down to a conflict with the aws-s3 gem
(which I was using for backup fu). Any thoughts on how to get these
two gems to live in a happy frappy world together?

Thanks,

Chris Williams

hunkybill

unread,
Aug 4, 2008, 2:41:52 PM8/4/08
to Paperclip Plugin
Hi,

I was really hoping this conflict was the answer to my problems. I
removed all references in my project to the aws-s3 gem, and tried
uploads to S3 with purely right-aws as the codebase. Lo and behold,
she bombs at the same place, same time, same channel... file saves to
S3 result in a conflict with Net::HTTP monkey patching...

I have not tried complete removal of the aws-gem from my system.. but
it sure would be nice to know why this is happening...

Did your code start working once you removed the gem?

Thanks for the insight...

Dave

On Jul 25, 11:32 am, "voodootiki...@gmail.com"

hunkybill

unread,
Aug 4, 2008, 3:02:04 PM8/4/08
to Paperclip Plugin
Success... I removed the gem aws-s3 from my system, and now Paperclip
uploads to S3.

I do not get my extensions for the new files...

but that is another issue!!

Thanks voodootikigod!!!

Dave

hunkybill

unread,
Aug 5, 2008, 1:44:54 PM8/5/08
to Paperclip Plugin
Extensions were actually not the problem... I had .tiff files with no
extension, and I accidentally processed those files instead of copies
that had the extension .tiff glued on...

Right on!!
> ...
>
> read more »
Reply all
Reply to author
Forward
0 new messages