Closed Yu-Chieh-Henry-Yang closed 1 year ago
Hi @Yu-Chieh-Henry-Yang, apologies if this is confusing.
timeout
is a setting for the whole request and thus is calculated for both opening the connection and reading the response (open/read). If the request hasn't finished after this threshold (even if some data have been received in the meantime), then it will timeout.
OTOH open_timeout
is only used to time the opening of the connection (i.e. time to first byte received). If the server replies with some data before this threshold, then no timeout will be raised (unless obviously the requests goes over the timeout
threshold.
You're right though the description for open_timeout
seems incorrect!
It should be :open_timeout - open timeout Integer in seconds
There are 2 more types of timeout, I've added a comment to explain them all to your PR 👍 Thank you for addressing this 🙏 !
Thanks for the explanation @iMacTia , I will continue the conversation in my PR. 🙏
We have these comment in the codebase: https://github.com/lostisland/faraday/blob/1a5b794b88ba897afca24e914b9b19297bc80473/lib/faraday/options/env.rb#L18-L19
:timeout
saysopen/read timeout Integer in seconds
:open_timeout
saysread timeout Integer in seconds
Question 1: Does this mean
timeout
includesopen_timeout
? For example, if everything times out at the limit and we configured to have 4 secondsopen_timeout
and 6 secondstimeout
, do we actually wait only 6 seconds (which includes the 4 seconds) or do we actually wait 4+6 = 10 seconds?Question 2:
:open_timeout
is called "open" timeout, why does it saysread timeout Integer in seconds
instead of something liketimeout Integer in seconds for opening connection
?Thank you very much.