solarwinds/orionsdk-python

timeout

steffenschumacher opened this issue · 11 comments

I experience timeout after 30 seconds, and I tried to modify the client module to increase timeout (passing the arg to requests module:

def _req(self, method, frag, data=None):
resp = requests.request(method, self.url + frag,
data=json.dumps(data, default=_json_serial),
verify=self.verify,
auth=self.credentials,
headers={'Content-Type': 'application/json'},
timeout=500.0)

Perhaps timeout should be exposed to users?
Secondly - my efforts did not work - I assume I need to tweak settings in the webserver..

Could you clarify what request took more than 30 seconds?

Hi,
Its a swis query, where I select all Cisco confines which do not have ssh enabled, only I confine the considered configurations to the most recent ones, which are a bit cumbersome - the equivalent sql query takes 90-120 seconds to execute.

Hi, I'm looking to implement timeouts also. I have another python module that uses requests and have gone through that adding in a timeout parameter to prevent issues with expired licenses causing the API to not respond correctly causing a non-response.
I was wondering if the Solarwinds API implements a standard timeout (as i see none in the swis client) or will the connection stay open indefinitely causing the initiating query to not receive a response?

Requests on the REST API have a 30 second timeout. This is not configurable or overridable at this time.

@tdanner Thanks for the confirmation.

In the orionsdk/swisclient.py can we edit line ~50 and add "timeout=15" to have the requests module have a 15 second timeout?

http://docs.python-requests.org/en/master/user/quickstart/#timeouts

Yes, you could tell requests to use a shorter client-side timeout. I don't think that this will affect what happens on the server though.

I just realized the original opening of this issue seems to be for the server side, my request is to add the timeout into the SDK client code as the requests python will never timeout, if it is not set.

Example reason why it would be a good idea to add this to the client:

I have a script that checks our SolarWinds instances for some data which does a swis.query() in a loop for each instance. If one of those instances is offline, or the network is down, my loop will never fail or error out as the requests module just sits waiting. I would be nice if the requests module had a hard set, or even configurable timeout of 15-30 seconds so that I can write a nice try/catch on the loop.

I can do a pull request if you'd like, but it is just a add of timeout=30, to line 54 in the swisclient.py. This would set the client SDK to the same timeout as the Orion server API timeout.

Your reasoning makes sense to me. PRs welcome. :)

Considering the fix for this has been implemented in PR #28 and documented in the README how to implement a timeout can someone close this issue as it appears to be resolved?

As @superadm1n noted, this has been resolved by #28.