Skip to content

request_timeout does not stop HTTP 599: Timeout #1753

Open

Description

@jkozlowicz

I am getting quite a few tornado.httpclient.HTTPError: HTTP 599: Timeout errors.

I read #1400 and I increased request_timeout for all my HTTPRequests to 2400.00 (40 minutes) then I rerun the code and I am 100% positive that I got not as many but still a few tornado.httpclient.HTTPError: HTTP 599: Timeout errors even thought my code finished running after 10 minutes.

I wonder why it is so and if there is something else I could do to fix it?

Activity

  1. bdarnell commented on Jun 17, 2016

    @bdarnell
    Member

    There are two timeouts: request_timeout and connect_timeout. If you want to prevent all HTTP 599: Timeout errors, you need to increase both.

  2. jkozlowicz commented on Jun 23, 2016

    @jkozlowicz
    Author

    But I understand that connect_timeout says how many seconds to wait since a request was sent (i.e. with the fetch function) until a response arrives, is that correct?

    What if I use an AsyncHTTPClient with max_clients set to X. If I called fetch method more than X does the connect_timeout timer already start counting?

  3. bdarnell commented on Jul 1, 2016

    @bdarnell
    Member

    request_timeout is supposed to cover the entire request end-to-end, from the time you call fetch() to the time you get the response. connect_timeout is only supposed to cover the time spent during DNS resolution and establishing the TCP connection. If you call fetch more than max_clients times, the time spent waiting in the queue is supposed to count for request_timeout but not for connect_timeout. However, there's currently a bug (in SimpleAsyncHTTPClient, not CurlAsyncHTTPClient) and both timeouts are running while you're in the queue (and then a separate bug in which both timers get reset when you transition from the queue to the active state).

    AsyncHTTPClient and its queueing and timeout settings are designed for interactive use. For batch crawling, you should probably be building your own scheduler in front of AsyncHTTPClient and only feed urls into AsyncHTTPClient as others finish (so you never wait in AsyncHTTPClient's queues, only your own where you can be smarter about prioritization and cancelation). See https://github.com/tornadoweb/tornado/blob/master/demos/webspider/webspider.py for an example.

  4. xenophonReal commented on Nov 10, 2016

    @xenophonReal

    Ben, when you say "(and then a separate bug in which both timers get reset when you transition from the queue to the active state)" do you mean reset to the original values passed? or to the default which i believe is 20s? Do you see this bug being fixed in the next version?

  5. bdarnell commented on Nov 20, 2016

    @bdarnell
    Member

    The bug is that the timers get reset to their configured values, so if you set request_timeout to 1 minute, the request could take up to two minutes (one minute in the queue, then one minute executing). I'm not likely to work on this bug any time soon but I'd accept a patch.

  6. ydaniv commented on Dec 6, 2016

    @ydaniv

    @bdarnell are the above mentioned bugs already opened as issues/PRs?
    If not could you give a pointer to files concerning the fix? perhaps I could give it a shot. Thanks!

  7. bdarnell commented on Dec 6, 2016

    @bdarnell
    Member

    This is the open issue. The fix would be in simple_httpclient.py; you'd need to capture the start time when the request is created (in SimpleAsyncHTTPClient.fetch_impl) and pass it in to the connection class instead of calling io_loop.time() again when the connection is created. request_timeout should be measured against this start_time while connect_timeout should be measured against the time the connection starts.

  8. jeffpeiyt commented on Feb 26, 2018

    @jeffpeiyt

    @bdarnell hi Ben, just to confirm this issue is still open? Can we confirm we still need to set connect_timeout to prevent a timeout and the bug there's currently a bug (in SimpleAsyncHTTPClient, not CurlAsyncHTTPClient) and both timeouts are running while you're in the queue is still there?

  9. bdarnell commented on Feb 26, 2018

    @bdarnell
    Member

    Yes, this issue is still open.

  10. jeffpeiyt commented on Feb 26, 2018

    @jeffpeiyt

    @bdarnell Ben, thanks for the prompt confirmation 👍

  11. damdo commented on Aug 9, 2019

    @damdo

    Hey @bdarnell are there any plans to tackle this? Thank you.

  12. bdarnell commented on Aug 12, 2019

    @bdarnell
    Member

    I don't have any plans to tackle this myself; PRs welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions