Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is "timeout" and "open timeout" in Faraday?

Since Faraday doesn't have documentation, I wasn't able to find it out anywhere. What is "timeout" and what "open timeout" in Faraday?

like image 456
janko-m Avatar asked Apr 25 '12 19:04

janko-m


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.

like image 76
Rich Drummond Avatar answered Sep 28 '22 05:09

Rich Drummond