You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
request_timeout does not stop HTTP 599: Timeout #1753
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?
Reacted by Wouter, rsj217, vEpiphyte, Jeff Pei, Fabio Natanael Kepler, Anirudh Chhangani, Marat Mavlyutov, Juan Pemberthy, Damiano Donati and pawciobiel
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?
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.
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?
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.
@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!
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.
@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?
Activity
bdarnell commentedon Jun 17, 2016
There are two timeouts: request_timeout and connect_timeout. If you want to prevent all
HTTP 599: Timeouterrors, you need to increase both.jkozlowicz commentedon Jun 23, 2016
But I understand that
connect_timeoutsays how many seconds to wait since a request was sent (i.e. with thefetchfunction) until a response arrives, is that correct?What if I use an
AsyncHTTPClientwithmax_clientsset toX. If I calledfetchmethod more thanXdoes theconnect_timeouttimer already start counting?bdarnell commentedon Jul 1, 2016
request_timeoutis supposed to cover the entire request end-to-end, from the time you callfetch()to the time you get the response.connect_timeoutis only supposed to cover the time spent during DNS resolution and establishing the TCP connection. If you callfetchmore thanmax_clientstimes, the time spent waiting in the queue is supposed to count forrequest_timeoutbut not forconnect_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).AsyncHTTPClientand its queueing and timeout settings are designed for interactive use. For batch crawling, you should probably be building your own scheduler in front ofAsyncHTTPClientand only feed urls intoAsyncHTTPClientas others finish (so you never wait inAsyncHTTPClient'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.xenophonReal commentedon Nov 10, 2016
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?
bdarnell commentedon Nov 20, 2016
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.
ydaniv commentedon Dec 6, 2016
@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!
bdarnell commentedon Dec 6, 2016
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_timeoutshould be measured against thisstart_timewhileconnect_timeoutshould be measured against the time the connection starts.jeffpeiyt commentedon Feb 26, 2018
@bdarnell hi Ben, just to confirm this issue is still open? Can we confirm we still need to set
connect_timeoutto prevent a timeout and the bugthere's currently a bug (in SimpleAsyncHTTPClient, not CurlAsyncHTTPClient) and both timeouts are running while you're in the queueis still there?bdarnell commentedon Feb 26, 2018
Yes, this issue is still open.
jeffpeiyt commentedon Feb 26, 2018
@bdarnell Ben, thanks for the prompt confirmation 👍
damdo commentedon Aug 9, 2019
Hey @bdarnell are there any plans to tackle this? Thank you.
bdarnell commentedon Aug 12, 2019
I don't have any plans to tackle this myself; PRs welcome.