Carl Youngblood [mailto:carl / youngbloods.org] wrote:

> I think the get and post timeout is set to 60 seconds by default.  Your 
> script would probably work if you increased the waiting time. My script 
> only times out every once in a while since it is accessing a real web 
> server that usually responds in time.

OK, that was it. Here's a quick server to duplicate the problem:

  require 'webrick'

  s = WEBrick::HTTPServer::new(:Port => 2000)
  s.mount_proc('/'){|req, resp| sleep(20); resp.body = "Hi!"}
  trap("INT"){s.stop}
  s.start

Here's a client that catches it for me:

  require 'net/http'

  h = Net::HTTP::new('localhost', 2000)
  h.read_timeout = 10
  begin
    puts "Trying..."
    resp = h.post('/', '')
    puts "Reply: #{resp.body}"
  rescue TimeoutError => e
    puts "Error: #{e.inspect}"
  end

My suggestion, rather than retrying the post, would be to simply bump up the
timeout using #read_timeout=. Retrying has the danger of continually trying
to get a page that takes 70 seconds to load using a 60 second timeout.

HTH,


Nathaniel

<:((><