-
Notifications
You must be signed in to change notification settings - Fork 37
Reconnect strategy
meghnas edited this page Jun 28, 2015
·
6 revisions
In case of a disconnection, the collector follows a strategy derived from the one Twitter recommends (https://dev.twitter.com/streaming/overview/connecting) but with a longer, configurable waiting time, and with randomization. Our back-off strategy is even more conservative than what Twitter recommends.
If the error has statusCode=-1
, i.e., it is a TCP/IP level error:
- Put the collection in the
WARNING
state. - Wait for
RECONNECT_NET_FAILURE_WAIT_SECONDS * RANDOM(1..3) * ATTEMPT_NUMBER
seconds.RANDOM(1...3)
is a floating point number between 1 and 3 (not an integer!).RECONNECT_NET_FAILURE_WAIT_SECONDS
is by default 60 seconds in the configuration file, the configuration must contain a comment near the point where this variable is defined, indicating that linear back-off will be used. - Try to re-connect. If re-connect is successful, set the collection to
RUNNING
state. - If
ATTEMPT_NUMBER++ > RECONNECT_NET_FAILURE_RETRY_ATTEMPTS
(configurable, default 5) times in a row, without receiving any tweet in between attempts, set the collection to theERROR
state.
If the error has statusCode == 420
, i.e. rate limit,
- Put the collection in the
WARNING
state. - Wait for
RECONNECT_RATE_LIMIT_WAIT_SECONDS * RANDOM(1..3) * (2^ATTEMPT_NUMBER)
, whereATTEMPT_NUMBER
is 0 initially. This generates exponentially increasing times.RECONNECT_RATE_LIMIT_WAIT_SECONDS
is 60 by default; the configuration file must include a comment near the point where that variable is defined, stating that this is the number recommended by Twitter and that exponential back-off will be used. - Try to re-connect. If re-connect is successful, set the collection to
RUNNING
state. - IF unsuccessful
ATTEMPT_NUMBER++ > RECONNECT_RATE_LIMIT_RETRY_ATTEMPTS
, set the collection to the ERROR state.
If the error has statusCode == 503
, i.e. service unavailable, the same as 420 above (linear back-off) but use config variables RECONNECT_SERVICE_UNAVAILABLE_WAIT_SECONDS
and RECONNECT_SERVICE_UNAVAILABLE_RETRY_ATTEMPTS
.
IF the error has statusCode == 401, 403, 404, 406, 413, 416
- Put the collection in the
ERROR
state.
- Home
- [What is AIDR?](AIDR Overview)
- The science behind AIDR
- [Operator's manual](AIDR Operator's Manual)
- [Public API documentation](API documentation)
- High-level overview
- Common
- DB Manager
- DTO standards
- Database schema
- Manager
- Manager API
- Collector
- Collector API
- Reconnect strategy
- Collector Tester
- Output
- Output API
- Output Buffered
- Output Streaming
- Output Tester
- Persister
- Persister API
- Persister Tester
- Tagger
- Tagger Concepts
- Tagger API
- Tagger Tester
- Trainer
- Trainer API
- PyBossa Trainer