Since Faraday doesn't have documentation, I wasn't able to find it out anywhere. What is "timeout" and what "open timeout" in Faraday?
1 Answers
If you look at the source code at https://github.com/lostisland/faraday/blob/master/lib/faraday/request.rb then you'll see:
# :timeout - open/read timeout Integer in seconds
# :open_timeout - read timeout Integer in seconds
Not very helpful, perhaps? Well, if you look at Faraday's Net::HTTP adapter at https://github.com/lostisland/faraday/blob/master/lib/faraday/adapter/net_http.rb, you'll see:
http.read_timeout = http.open_timeout = req[:timeout] if req[:timeout]
http.open_timeout = req[:open_timeout] if req[:open_timeout]
So Faraday's open_timeout is equivalent to Net::HTTP's open_timeout which is documented as:
Number of seconds to wait for the connection to open. Any number may be used, including Floats for fractional seconds. If the HTTP object cannot open a connection in this many seconds, it raises a TimeoutError exception.
And Faraday's timeout is equivalent to Net::HTTP's read_timeout which is documented as:
Number of seconds to wait for one block to be read (via one read(2) call). Any number may be used, including Floats for fractional seconds. If the HTTP object cannot read data in this many seconds, it raises a TimeoutError exception.

- 5,110
- 1
- 33
- 62

- 3,439
- 1
- 15
- 16
-
2Awesome answer, thanks :). Yeah, I also came across the Faraday's description, and yeah, it wasn't very helpful. But this is really great :) – Janko Apr 26 '12 at 11:43
-
1Still a great answer! – SexxLuthor Jul 21 '20 at 15:14
-
Does `timeout` includes `open_timeout`? For example, if everything times out at the limit and we configured to have 4 seconds `open_timeout` and 6 seconds `timeout`, do we actually wait only 6 seconds (which includes the 4 seconds) or do we actually wait 4+6 = 10 seconds? – Henry Yang Dec 14 '22 at 05:53
-
That Github link is not available anymore; but here's the current location: https://github.com/lostisland/faraday-net_http/blob/main/lib/faraday/adapter/net_http.rb#L152 – Sinan Kucukkoseler Mar 14 '23 at 10:08