2

Although I raised the timeout for Net::HTTP:

http = Net::HTTP.new(uri.host, uri.port)
http.open_timeout = 60
http.read_timeout = 60
response = http.post(uri.path, body, headers)

I keep getting these errors:

Timeout::Error at /
execution expired
file: http.rb location: initialize line: 762 

It's a pretty long time for timeout I guess, and I should not get these errors, should I? I also read a couple of articles that described how to increase the timeout using ways different from mine. It gets me confused: For such a simple thing there are a lot of different and complicated solutions, and I don't know which one is correct.

What are your ideas about the correct way of increasing timeout? And, how do I check if I did it correctly?

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
  • 1
    So how long did the request take to timeout? – Frederick Cheung Jan 14 '13 at 08:00
  • 1
    possible duplicate of [Ruby net http time out](http://stackoverflow.com/questions/2229194/ruby-net-http-time-out) – philant Jan 14 '13 at 09:04
  • @FrederickCheung, it takes about 5 seconds, possibly a bit less. –  Jan 14 '13 at 11:53
  • @philant, that's why I asked the question. It's weird to "patch" the class `@read_timeout = 5*60 # 5 minutes` instead of just say `http.open_timeout = 50` and `http.read_timeout = 50`. –  Jan 14 '13 at 11:55
  • possible duplicate of [Net::HTTP get timeout in Ruby](http://stackoverflow.com/questions/19325479/nethttp-get-timeout-in-ruby). Should be the other way around because this is older, but stackoverflow does not allow to mark duplicates of questions without upvoted answers...... Both tried read and open timeout. – Ciro Santilli OurBigBook.com Oct 11 '14 at 15:33

0 Answers0