http icon indicating copy to clipboard operation
http copied to clipboard

Timeout after 0.25 seconds

Open HashNotAdam opened this issue 5 years ago • 8 comments

I'm using HTTP with Savon and I'm getting intermittent timeout errors.

HTTP::TimeoutError: Read timed out after 0.25 seconds

I can assure you I'm not setting the read_timeout to 0.25 but the problem is the API I'm connecting to is private and can only be accessed on whitelisted servers so I'm not able to submit example code that reproduces the issue.

I've now told Savon to use Net::HTTP and the issue is gone but felt I should still see if there is some way for me to help debug and fix the issue.

HashNotAdam avatar Dec 22 '19 08:12 HashNotAdam

Please, provide minimal code that we can use to reproduce bug.

ixti avatar Dec 22 '19 16:12 ixti

Do you know of an open SOAP API I could use for the code? I'd like to help debug this but, as stated, I can't provide access to the API I'm using.

HashNotAdam avatar Dec 22 '19 23:12 HashNotAdam

There aren’t any hardcoded 0.25s timeouts in http.rb AFAIK. What Savon adapter are you using? If you’re filing an issue here, it by definition isn’t SOAP-specific.

tarcieri avatar Dec 23 '19 00:12 tarcieri

@tarcieri obviously I was using HTTP as an adapter or I wouldn't be here. And I hear what you're saying about it not being SOAP-specific but I still use HTTP for all my non-SOAP requests and it's clear from the lack of issues here that it isn't a bug most people are seeing so it must either be something about the settings used by Savon to make a SOAP request or something about the sever. The issue only occurred after a minor upgrade to HTTP so I'll see if I can bisect the commit that introduced the issue

HashNotAdam avatar Dec 27 '19 23:12 HashNotAdam

So, version 2.4.4 of Savon's associated gem, HTTPI, started setting the timeouts by passing a hash into HTTPs timeout method which is setting the timeouts as PerOperation.

Even though only a connect timeout is being set, the PerOperation class sets all 3 timeouts and, if no value is passed in, it defaults to 0.25 seconds.

Not only is 0.25 seconds is insanely small but I can't see that being documented anywhere. The timeouts documentation simply states that you can set timeouts per operation but not that it will default to a value completely different from what you'd get if we set none of the timeouts.

HashNotAdam avatar Dec 28 '19 01:12 HashNotAdam

@HashNotAdam aha, see them now:

https://github.com/httprb/http/blob/master/lib/http/timeout/per_operation.rb#L10-L12

Yes, these timeouts are ridiculously low. I'd support a PR to turn them all up (to say, 10 seconds).

I think that might be something of a semver breaking change, but that's also debatable.

tarcieri avatar Dec 28 '19 01:12 tarcieri

Given the default is to not set a timeout (at least as I understand it), could I suggest that only the specified timeouts are set and the others remain empty?

HashNotAdam avatar Jan 03 '20 03:01 HashNotAdam

That makes sense (but is probably also a semver breaking change)

tarcieri avatar Jan 03 '20 03:01 tarcieri