12

In the Ruby RestClient gem, what's the difference between the timeout and open-timeout functionality?

http://www.ruby-doc.org/gems/docs/w/wgibbs-rest-client-1.0.5/RestClient/Resource.html#method-i-open_timeout

I didn't get anything from the doc file of the gem either.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Pratik Bothra
  • 2,642
  • 2
  • 30
  • 44

1 Answers1

16

You're reading the wrong documentation (yours is for wgibbs-rest-client which has not been updated since 2009): here's the right one. But that one does not say anything about the difference either, although it is simple:

:open_timeout is the timeout for opening the connection. This is useful if you are calling servers with slow or shaky response times.

:timeout is the timeout for reading the answer. This is useful to make sure you will not get stuck half way in the reading process, or get stuck reading a 5 MB file when you're expecting 5 KB of JSON.

Beat Richartz
  • 9,474
  • 1
  • 33
  • 50
  • Thanks....Just to confirm response = RestClient.get "abc/order_items/advanced_search?" would be equivalent to response = RestClient::Request.execute(:method => :get, :url => "abc/order_items/advanced_search?", :timeout => 300) – Pratik Bothra Apr 17 '13 at 13:34
  • Yes, `RestClient.get` is calling `execute` like this: `Request.execute(:method => :get, :url => url, :headers => headers, &block)` – Beat Richartz Apr 17 '13 at 13:58