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: CampaignTopic.post(:icon_attachments_rebuild_and_save, :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 Errno::ECONNRESET 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:in `write0'' 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:in `writing'' 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:in `write_header'' D:/dev/rubyonrails/ruby/lib/ruby/1.8/net/http.rb:1548:in `send_request_with_body'' D:/dev/rubyonrails/ruby/lib/ruby/1.8/net/http.rb:1534:in `exec'' 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:in `request'' 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:in `request'' 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:in `send'' D:/dev/rubyonrails/ruby/lib/ruby/gems/1.8/gems/activeresource-2.3.2/ 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:in `ms'' D:/dev/rubyonrails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/ 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:in `ms'' D:/dev/rubyonrails/ruby/lib/ruby/gems/1.8/gems/activeresource-2.3.2/ 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:in `post'' D:/dev/rubyonrails/ruby/lib/ruby/gems/1.8/gems/activeresource-2.3.2/ lib/active_resource/custom_methods.rb:61:in `post'' D:/.../.../../.../.../../internal/trunk/app/controllers/ campaign_topics_controller.rb:92:in `create'' 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 ...
Zach Karpinski
2009-Jul-22 14:02 UTC
Re: Problem sending files > ~10KB using Active Resource
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 database. 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. On Jul 22, 7:53 am, onomato <ger...-D8BpJeV/e+tWk0Htik3J/w@public.gmane.org> wrote:> 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: > > CampaignTopic.post(:icon_attachments_rebuild_and_save, :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 > Errno::ECONNRESET > 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:in `write0'' > 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:in `writing'' > 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:in > `write_header'' > D:/dev/rubyonrails/ruby/lib/ruby/1.8/net/http.rb:1548:in > `send_request_with_body'' > D:/dev/rubyonrails/ruby/lib/ruby/1.8/net/http.rb:1534:in `exec'' > 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:in `request'' > 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:in `request'' > 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:in `send'' > D:/dev/rubyonrails/ruby/lib/ruby/gems/1.8/gems/activeresource-2.3.2/ > 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:in `ms'' > D:/dev/rubyonrails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/ > 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:in `ms'' > D:/dev/rubyonrails/ruby/lib/ruby/gems/1.8/gems/activeresource-2.3.2/ > 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:in `post'' > D:/dev/rubyonrails/ruby/lib/ruby/gems/1.8/gems/activeresource-2.3.2/ > lib/active_resource/custom_methods.rb:61:in `post'' > D:/.../.../../.../.../../internal/trunk/app/controllers/ > campaign_topics_controller.rb:92:in `create'' > > 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 ...