redouane59 / twittered

Twitter API client for Java developers
Apache License 2.0
234 stars 64 forks source link

IllegalArgumentException: timeout value is negative #440

Open swisstechguy opened 1 year ago

swisstechguy commented 1 year ago

The following error occurs in long during searchAll queries:

07:19:55.057 [main ] INFO i.g.r.t.h.AbstractRequestHelper Rate limit exceeded, new retry in at 07:19 07:19:55.058 [main ] ERROR c.z.n.b.twitter.TweetsCatcher ERROR catched in main, wait 60s and restart java.lang.IllegalArgumentException: timeout value is negative at java.base/java.lang.Thread.sleep(Native Method) at io.github.redouane59.twitter.helpers.AbstractRequestHelper.makeRequest(AbstractRequestHelper.java:104) at io.github.redouane59.twitter.helpers.AbstractRequestHelper.makeRequest(AbstractRequestHelper.java:76) at io.github.redouane59.twitter.helpers.AbstractRequestHelper.makeRequest(AbstractRequestHelper.java:54) at io.github.redouane59.twitter.helpers.RequestHelperV2.getRequestWithParameters(RequestHelperV2.java:50) at io.github.redouane59.twitter.TwitterClient.getTweetsRecursively(TwitterClient.java:910) at io.github.redouane59.twitter.TwitterClient.searchAllTweets(TwitterClient.java:899)

The problem is since version 2.20 since the AbstractRequestHelper reads 'x-rate-limit-reset' in line 92.

solution: check retryAfter for negative values and don't sleep if retryAfter is negative.

Thanks for this great project!

redouane59 commented 1 year ago

Hello, thanks for the issue.

Do you think you could submit a PR ? Then I'll be able to release a new version as talked here : https://github.com/redouane59/twittered/issues/438

swisstechguy commented 1 year ago

yes, I can do that. where can I commit?

redouane59 commented 1 year ago

Just fork the project, do your job, and then submit a Pull Request to this repository :)

swisstechguy commented 1 year ago

done, thanks.