Berger, Daniel
2006-Apr-21 17:45 UTC
[Rails] Problem with Mongrel, Rails and web services using xmlrpc
Hi all, Ruby 1.8.4 Windows XP Pro / Solaris 10 Mongrel 0.3.12 Rails 1.1.2 I''ve got a fairly simple and straightforward layered dispatching web service setup for my Rails app. This simple xmlrpc script works fine with WEBrick, but chokes on Mongrel. Is there anything special I need to do to make web services work with Mongrel and Rails? Some Google searching indicates that there had been some xmlrpc issues in the past with Mongrel but I thought they were worked out. Anyway, here''s the script and error: # xmlrpctest.rb require ''xmlrpc/client'' rpc = XMLRPC::Client.new(''localhost'', ''http://localhost/webservice/api'', 3000) rpc.call(''hardware.FindHardwareById'', 2) c:/ruby/lib/ruby/1.8/net/protocol.rb:133:in `sysread'': Invalid argument (Errno::EINVAL) from c:/ruby/lib/ruby/1.8/net/protocol.rb:133:in `rbuf_fill'' from c:/ruby/lib/ruby/1.8/timeout.rb:56:in `timeout'' from c:/ruby/lib/ruby/1.8/timeout.rb:76:in `timeout'' from c:/ruby/lib/ruby/1.8/net/protocol.rb:132:in `rbuf_fill'' from c:/ruby/lib/ruby/1.8/net/protocol.rb:116:in `readuntil'' from c:/ruby/lib/ruby/1.8/net/protocol.rb:126:in `readline'' from c:/ruby/lib/ruby/1.8/net/http.rb:1988:in `read_status_line'' from c:/ruby/lib/ruby/1.8/net/http.rb:1977:in `read_new'' from c:/ruby/lib/ruby/1.8/net/http.rb:1046:in `request'' from c:/ruby/lib/ruby/1.8/net/http.rb:1033:in `request'' from c:/ruby/lib/ruby/1.8/net/http.rb:545:in `start'' from c:/ruby/lib/ruby/1.8/net/http.rb:1031:in `request'' from c:/ruby/lib/ruby/1.8/net/http.rb:988:in `post2'' from c:/ruby/lib/ruby/1.8/xmlrpc/client.rb:535:in `do_rpc'' from c:/ruby/lib/ruby/1.8/xmlrpc/client.rb:420:in `call2'' from c:/ruby/lib/ruby/1.8/xmlrpc/client.rb:410:in `call'' from xmlrpctest.rb:13
Zed Shaw
2006-Apr-21 18:25 UTC
[Rails] Problem with Mongrel, Rails and web services using xmlrpc
On 4/21/06 1:44 PM, "Berger, Daniel" <Daniel.Berger@qwest.com> wrote:> Hi all, > > Ruby 1.8.4 > Windows XP Pro / Solaris 10 > Mongrel 0.3.12 > Rails 1.1.2 > > I''ve got a fairly simple and straightforward layered dispatching web > service setup for my Rails app. This simple xmlrpc script works fine > with WEBrick, but chokes on Mongrel. Is there anything special I need > to do to make web services work with Mongrel and Rails? Some Google > searching indicates that there had been some xmlrpc issues in the past > with Mongrel but I thought they were worked out. > > Anyway, here''s the script and error: >Are you inside a Rails controller/action and then trying to connect back to the same Rails application via xmlrpc? Mongrel has to lock Rails to keep it sane, so if you''re inside a Rails app, and then connect back to the same app via HTTP you''ll get a dead-lock. Also, can you run your setup with "mongrel_rails start -B" and see what headers are being dumped in the log/mongrel_debug/rails.log? Finally, can you shoot me the other half of the sample or a simplified xml-rpc rails test case? With that I can run it through and make sure it always works with Mongrel in the future. Zed A. Shaw http://www.zedshaw.com/ http://mongrel.rubyforge.org/
Berger, Daniel
2006-Apr-21 19:08 UTC
[Rails] Problem with Mongrel, Rails and web services using xmlrpc
> -----Original Message----- > From: rails-bounces@lists.rubyonrails.org > [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Zed Shaw > Sent: Friday, April 21, 2006 12:23 PM > To: rails@lists.rubyonrails.org > Subject: Re: [Rails] Problem with Mongrel, Rails and web > services using xmlrpc<snip>> Are you inside a Rails controller/action and then trying to > connect back to the same Rails application via xmlrpc? > Mongrel has to lock Rails to keep it sane, so if you''re > inside a Rails app, and then connect back to the same app via > HTTP you''ll get a dead-lock.Nope. This is just an external script I use as a sanity check.> Also, can you run your setup with "mongrel_rails start -B" > and see what headers are being dumped in the > log/mongrel_debug/rails.log?Running that sample script doesn''t appear to generate anything in the rails.log file. Odd.> Finally, can you shoot me the other half of the sample or a > simplified xml-rpc rails test case? With that I can run it > through and make sure it always works with Mongrel in the future.# hardware_api.rb under /app/apis class HardwareApi < ActionWebService::API::Base api_method :find_hardware_by_id, :expects => [:int], :returns => [Hardware] end # hardware_service.rb under /app/apis class HardwareService < ActionWebService::Base web_service_api HardwareApi # Returns a Hardware object by id. def find_hardware_by_id(id) Hardware.find(id) end end # hardware.rb under /app/model class Hardware < ActiveRecord::Base set_table_name "hardware" has_many :schedules end The HardwareController is pretty straightforward, as is the hardware table. Is there anything I''ve missed that you need? Thanks, Dan
Zed Shaw
2006-Apr-21 23:29 UTC
[Rails] Problem with Mongrel, Rails and web services using xmlrpc
On 4/21/06 3:08 PM, "Berger, Daniel" <Daniel.Berger@qwest.com> wrote:>> -----Original Message----- > snip>> Also, can you run your setup with "mongrel_rails start -B" >> and see what headers are being dumped in the >> log/mongrel_debug/rails.log? > > Running that sample script doesn''t appear to generate anything > in the rails.log file. Odd. >Seriously? No way. Either the request is getting blocked as bad HTTP or something else is up because the rails.log is written long before rails is even touched. If you''re not seeing anything there then the request isn''t event going to the right place.>> Finally, can you shoot me the other half of the sample or a >> simplified xml-rpc rails test case? With that I can run it >> through and make sure it always works with Mongrel in the future. > > snip> Is there anything I''ve missed that you need? >Nope, that should do it. I''ll test it out late tonight and see what''s up. Zed A. Shaw http://www.zedshaw.com/ http://mongrel.rubyforge.org/
Reasonably Related Threads
- Configuring libvirt for one driver and XMLRPC issues
- How to pass an additional parameter from the url to a xmlrpc service?
- Passing XMLRPC errors on to clients
- Webservice External XMLRPC
- Bug#477237: xen-utils-common: typo in /etc/xen/xend-config.sxp for xmlrpc configuration