From: Eric Hodel Date: 2011-07-23T06:56:35+09:00 Subject: Re: open localhost url On Jul 22, 2011, at 11:59 AM, Smp Mp wrote: > When I call call the below code I get a timeout. > > > http_object = Net::HTTP.new("localhost", "3000") > hresp, data = > http_object.get("/documents/wdocs/generatedata?"+query_string ,"", nil) > > > But when application is running on port 3000 and a copy of the same > application is running on a different port(3001) , then it works fine. > > http_object = Net::HTTP.new("localhost", "3001") > hresp, data = > http_object.get("/documents/wdocs/generatedata?"+query_string ,"", nil) > > the code is called from test_controller. is there any way i could call > the url? > > Timeout::Error (execution expired): > C:/jruby-1.4.0/lib/ruby/1.8/net/protocol.rb:135:in `rbuf_fill' > C:/jruby-1.4.0/lib/ruby/1.8/net/protocol.rb:134:in `rbuf_fill' > C:/jruby-1.4.0/lib/ruby/1.8/net/protocol.rb:116:in `readuntil' > C:/jruby-1.4.0/lib/ruby/1.8/net/protocol.rb:126:in `readline' > C:/jruby-1.4.0/lib/ruby/1.8/net/http.rb:2020:in `read_status_line' > C:/jruby-1.4.0/lib/ruby/1.8/net/http.rb:2009:in `read_new' > C:/jruby-1.4.0/lib/ruby/1.8/net/http.rb:1050:in `request' > app/controllers/documents/test_controller.rb:123:in `index' > C:/jruby-1.4.0/lib/ruby/1.8/net/http.rb:543:in `start' > app/controllers/documents/test_controller.rb:118:in `index' > C:/jruby-1.4.0/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' > C:/jruby-1.4.0/lib/ruby/1.8/webrick/httpserver.rb:65:in `run' > C:/jruby-1.4.0/lib/ruby/1.8/webrick/server.rb:173:in `start_thread' > C:/jruby-1.4.0/lib/ruby/1.8/webrick/server.rb:162:in `start' > C:/jruby-1.4.0/lib/ruby/1.8/webrick/server.rb:162:in `start_thread' > C:/jruby-1.4.0/lib/ruby/1.8/webrick/server.rb:95:in `start' > C:/jruby-1.4.0/lib/ruby/1.8/webrick/server.rb:92:in `each' > C:/jruby-1.4.0/lib/ruby/1.8/webrick/server.rb:92:in `start' > C:/jruby-1.4.0/lib/ruby/1.8/webrick/server.rb:23:in `start' > C:/jruby-1.4.0/lib/ruby/1.8/webrick/server.rb:82:in `start' > script\server:3 I would bet that the server only allows one request at a time, so trying to perform an HTTP request against yourself won't work. This makes me wonder why you're performing an HTTP request against yourself and not calling yourself internally using ruby.