Hey,
I am trying to use the
error.rate_limit.reset_in delay from Twitter::Error::TooManyRequests to sleep the thread for x seconds before restarting the streaming client, but for me this param is always blank.
I'm basing my reconnection logic on the example provided:
https://github.com/sferik/twitter/blob/master/examples/RateLimiting.md but in case it's related to something else in my code, I've ripped out lots of other code but this is basically identical to the main reconnection logic:
def client
Twitter::Streaming::Client.new do |config|
config.consumer_key = [hidden]
config.consumer_secret = [hidden]
config.access_token = [hidden]
config.access_token_secret = [hidden]
end
end
def start_search(keywords)
client.filter track: keywords do |item|
save! item
rescue Twitter::Error::TooManyRequests => error
puts 'Twitter::Error::TooManyRequests error'
# TODO: Twitter gem isn't providing a rate_limit here, how come??
delay = error.rate_limit.reset_in || 180
sleep delay + 1
start_search keywords
end
end
Always resorts to 180 seconds delay (well, 181) - reset_in is always nil.
Any advice would be gratefully received.