What is the difference between timeout and open timeout?
Asked Answered
W

1

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.

Wow answered 17/4, 2013 at 12:59 Comment(0)
A
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.

Angloindian answered 17/4, 2013 at 13:18 Comment(2)
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)Wow
Yes, RestClient.get is calling execute like this: Request.execute(:method => :get, :url => url, :headers => headers, &block)Angloindian

© 2022 - 2024 — McMap. All rights reserved.