conn.get do |req|
req.url '/search'
req.options.timeout = 5 # open/read timeout in seconds
req.options.open_timeout = 2 # connection open timeout in seconds
end
open_timeout[RW]
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 Net::OpenTimeout exception. The default value is nil .
By the way, please translate it:
open_timeout
Set the maximum waiting time when opening a connection. Its value can be any number, including very small floating point numbers. If the connected painting cannot be opened within the set time period, a Net::OpenTimeout exception will be thrown. The default value is nil, which means no time limit.
This will limit the request to be completed within 30 seconds.
There are also many other functions, such as setting proxy servers, CA certificates, ssl certificates, etc.
You can refer to the documentation for details, so I won’t go into details here.
https://github.com/lostisland/faraday
No need to bother, just use Net::HTTP
This is the document introduction:
By the way, please translate it:
There are also many other functions, such as setting proxy servers, CA certificates, ssl certificates, etc.
You can refer to the documentation for details, so I won’t go into details here.