Using Connection HTTP timeouts - rapid7/nexpose-client GitHub Wiki
How to use Nexpose-client HTTP Timeouts
This is a new Feature found in v7.0.0
Generally speaking, you should not need to edit either of the default 120second timeouts while using this gem. However, there comes a time when one must perform a large task, or complete a bulk operation which could possibly take longer than the 120second defaults.
There are two different http timeouts available to the Nexpose::Connection object, and the values are the number of seconds to wait.
The Nexpose::Connection.timeout attribute is mapped to Ruby's http :read_timeout value, while Nexpose::Connection.open_timeout uses the same name of Ruby's http :open_timeout attribute.
:exclamation: Before adjusting either timeout value, be sure to understand how they are used by Ruby. :exclamation:
Usage:
nsc = Nexpose::Connection.new(hostname, username, password)
You can edit the timeouts anytime after the creation of the Connection object.
Just set the number of seconds to wait until we timeout.
nsc.timeout = 10
=> 10
nsc.open_timeout = 10
=> 10
nsc.login
=> true
nsc
=> #<Nexpose::Connection:0x000000001
<~ output condensed ~>
@host="localhost",
@open_timeout=10,
@timeout=10,
@username="username">
:exclamation: These timeouts will now be used for all http(s) requests going forward. :exclamation:
Error Output:
Both of Ruby's HTTP timeouts, :read_timeout and :open_timeout throw different errors, and the log output of nexpose-client will look similar for both. But we will include in the log message, which Timeout error was raised.
nsc.timeout = 10
=> 10
nsc.list_assets
=> Nexpose::APIError: NexposeAPI: Action failed:
Nexpose did not respond within 10 seconds Net::ReadTimeout.
Reference the Wiki for information on setting the different Timeout values.
nsc.open_timeout = 20
=> 20
nsc.list_assets
=> Nexpose::APIError: NexposeAPI: Action failed:
Nexpose did not respond within 20 seconds Net::OpenTimeout.
Reference the Wiki for information on setting the different Timeout values.
This will allow to help troubleshoot which timeout to adjust.