Problem sending files > ~10KB using Active Resource

Hey everybody,

scenario: frontend-server gets files from a form.file_field and should
send the filedata to a backend-server via (Hyper)ActiveResource!

I used the following code to access a method in a backend-server and
send the filedata:, :filedata =>
params[:campaign_topic][:icon_brand].read, :content_type => params
[:campaign_topic][:icon_brand].content_typ )

This works fine for files less than ~10KB, otherwise a get a
An existing connection was forcibly closed by the remote host.

Application Trace:
D:/dev/rubyonrails/ruby/lib/ruby/1.8/net/protocol.rb:175:in write' D:/dev/rubyonrails/ruby/lib/ruby/1.8/net/protocol.rb:175:inwrite0’
D:/dev/rubyonrails/ruby/lib/ruby/1.8/net/protocol.rb:151:in write' D:/dev/rubyonrails/ruby/lib/ruby/1.8/net/protocol.rb:166:inwriting’
D:/dev/rubyonrails/ruby/lib/ruby/1.8/net/protocol.rb:150:in write' D:/dev/rubyonrails/ruby/lib/ruby/1.8/net/http.rb:1583:inwrite_header’
send_request_with_body' D:/dev/rubyonrails/ruby/lib/ruby/1.8/net/http.rb:1534:inexec’
D:/dev/rubyonrails/ruby/lib/ruby/1.8/net/http.rb:1057:in request' D:/dev/rubyonrails/ruby/lib/ruby/1.8/net/http.rb:1046:inrequest’
D:/dev/rubyonrails/ruby/lib/ruby/1.8/net/http.rb:547:in start' D:/dev/rubyonrails/ruby/lib/ruby/1.8/net/http.rb:1044:inrequest’
D:/dev/rubyonrails/ruby/lib/ruby/1.8/net/http.rb:854:in post' D:/dev/rubyonrails/ruby/lib/ruby/gems/1.8/gems/activeresource-2.3.2/ lib/active_resource/connection.rb:149:insend’
lib/active_resource/connection.rb:149:in request' D:/dev/rubyonrails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/ active_support/core_ext/benchmark.rb:17:inms’
active_support/core_ext/benchmark.rb:10:in realtime' D:/dev/rubyonrails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/ active_support/core_ext/benchmark.rb:17:inms’
lib/active_resource/connection.rb:149:in request' D:/dev/rubyonrails/ruby/lib/ruby/gems/1.8/gems/activeresource-2.3.2/ lib/active_resource/connection.rb:134:inpost’
lib/active_resource/custom_methods.rb:61:in post' D:/.../.../../.../.../../internal/trunk/app/controllers/ campaign_topics_controller.rb:92:increate’

The Point is, that the request doesn’t contact the backend-method, so
it’s the code posted above which causes the connection to be closed.
Has anyone any idea what the problem might be?

thanks for help …

What web server and how are you serving rails?

I have a caching media server built in rails and I ran into a couple
problems that look identical to this. First I was on Apache2 with
Ruby Enterprise Edition and Passenger Phusion using MySQL as the

In my case I needed to do two things. First give passenger phusion a
LimitRequestBody value. I set this pretty high, well over 100MB
(LimitRequestBody 104857600). You can just paste that into your
virtual host config file for this site. Second I had to tell MySQL
to use a larger maximum packet size. max_allowed_packet = 100M in the
[mysqld] section of my.cnf.

I am no expert when it comes to how MySQL does its network connections
and am not sure if the whole max packet thing should match the
LimitRequestBody or not. I figured that the file and data being sent
to MySQL was going to be smaller than the request that passenger
handles so a little extra on the LimitRequestBody wouldn’t hurt.

After upgrading passenger to the latest version my Errno::ECONNRESET
errors went away.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs