arago/graphit-tool

No controls for timeouts.

Opened this issue · 1 comments

Great piece of code!

When trying to use the tool, I got a timeout error for WSO2 connection (using DNS, not /etc/hosts):

Could not connect to WSO2: ('Connection aborted.', DNSError(67, 'request timed out'))

I looked at the configuration files and everything was just fine (graphit-tool.py was working before!).

After reviewing the code and debugging the connection to IAM, I found that the first time it tried to connect, it failed with a timeout, the WSO2 logs did not show any attempt to connect (usually would get a 401 error), but if you send a second request to connect it would take it (200).

Quick ugly workaround:

        try:
               session.auth = WSO2AuthClientCredentials(
                       config.get('wso2', 'url'),
                       client = (
                               config.get('wso2', 'clientid'),
                               config.get('wso2', 'clientsecret')
                       ),
                       verify=wso2_verify)
       except:
               try:
                       session.auth = WSO2AuthClientCredentials(
                               config.get('wso2', 'url'),
                               client = (
                                       config.get('wso2', 'clientid'),
                                       config.get('wso2', 'clientsecret')
                               ),
                       verify=wso2_verify)
               except WSO2Error as e:
                       print >>sys.stderr, e
                       sys.exit(10)

Looping would get it to work.

Thanks, I will try to generalize this. The goals should be:

  1. Arbitrary number of repetitions (as you said, looping)
  2. Exponential backoff, so it doesn't stress an possibly already overloaded WSO2 with additional thousand connections per second.
  3. A (configurable) timeout.