hyper icon indicating copy to clipboard operation
hyper copied to clipboard

Timeout handling

Open farefernandez opened this issue 8 years ago • 12 comments

Hi,

I'm using Hyper to connect to a HTTP/2 website and I'd like to be able to control timeouts (connection, read, dns resolver).

I don't seem to be able to find mentions to timeout handling in the documentation so I assume this could be seen as a feature request.

Thanks!

farefernandez avatar Dec 24 '15 12:12 farefernandez

Yup, this seems like a good feature request to me!

Lukasa avatar Dec 24 '15 12:12 Lukasa

Thanks Cory.

API-wise, we could have one global, coarse-grained timeout parameter which could refer to the sum of all of the components (connect, read, dns). This is what people usually should use.

Fine-grained timeouts could be added with specific parameters controlling each of the components.

farefernandez avatar Dec 24 '15 12:12 farefernandez

For reference, this is how requests does it (although the dns resolver timeout doesn't seem to be handled): http://docs.python-requests.org/en/latest/user/advanced/#timeouts

Relevant DNS resolver discussion: https://bugs.python.org/issue22889

Thanks!

farefernandez avatar Dec 24 '15 12:12 farefernandez

@farefernandez I'm a bit nervous about implementing an extremely complex timeout logic. However, if you were going in that direction the thing to do is to look at urllib3's Timeout logic and see if we can implement something somewhat similar.

Lukasa avatar Dec 24 '15 12:12 Lukasa

Hi All,

I'm getting this error consistently on response.read()

ssl.SSLError: ('The read operation timed out',)

Does this issue mean that this can't be handled currently?

Thank you for hyper!

johnwheeler avatar Aug 22 '16 23:08 johnwheeler

@johnwheeler I think that depends on what you mean by "handled". What would you define as handled here?

Lukasa avatar Aug 22 '16 23:08 Lukasa

Thank you for the quick response. Handled was a poor word choice since it connotes exception handling. I was wondering if there's a way to stop this error from occurring and proceed to read the data, and I want to confirm that:

  1. There's no way to do that per this issue (no way to set a timeout)
  2. I'm not misunderstanding the HTTP/2 protocol and this error makes it immediately apparent to you how.

Thanks again

johnwheeler avatar Aug 22 '16 23:08 johnwheeler

Please disregard. I just don't know what I'm doing. I think I'm trying to interact with a HTTP/2 service in an HTTP/1 way and didn't make it far enough in your docs. I've gotten further along now, and it looks like I'm making headway.

FYI - I'm using this library to connect to the Alexa Voice Service, which is Amazon's Echo service for building the Echo into your own hardware.

johnwheeler avatar Aug 23 '16 00:08 johnwheeler

Ah I'm glad you've worked it through!

Lukasa avatar Aug 23 '16 01:08 Lukasa

Hi,

I deleted my last comment because I realized HTTP20Connection's connect is not part of the public API.

Does it make sense to add to add a timeout parameter to HTTPConnection init method that is used during socket creation?

i.e. in HTTP20Connection.connect, it'd be something like:

sock = socket.create_connection((host, port))
sock.settimeout(self._sock_timeout)

If this is a good idea, I can attempt a PR

johnwheeler avatar Aug 24 '16 02:08 johnwheeler

@johnwheeler I would accept a PR that does that, yeah. =)

Lukasa avatar Aug 24 '16 14:08 Lukasa

Is controlling timeout not yet?

If not, does it have a timeout internally used by default?

asleea88 avatar Jan 18 '19 06:01 asleea88