twittered
twittered copied to clipboard
Allow timeout to be specified to TwitterClient.stopFilteredStream()
I've been dealing with strange network timeouts during filtered streams recently, and while I was able to supply network timeouts to the HTTP layer by switching to Scribe's Apache HTTP client backend, twittered doesn't have a way to supply a timeout to TwitterClient.stopFilteredStream()
. Below is a stack trace showing the cancellation taking 25 minutes when it should be much closer to the 1 minute timeout I specified to the HTTP layer. (TwitterProducer
is my code and is what calls TwitterClient.stopFilteredStream()
with the future as dictated in the twittered documentation.)
2022-09-10 03:51:56,481 [TwitterProducer-scheduled-0] WARN t.worker.TwitterProducer - Failed to close null
java.util.concurrent.TimeoutException: null
at com.github.scribejava.httpclient.apache.OAuthAsyncCompletionHandler.getResult(OAuthAsyncCompletionHandler.java:103)
at com.github.scribejava.httpclient.apache.ApacheHttpFuture.get(ApacheHttpFuture.java:42)
at twitter2mastodon.worker.TwitterProducer.lambda$refreshWatch$46(TwitterProducer.java:649)
2022-09-10 04:14:19,366 [I/O dispatcher 1] ERROR i.g.r.t.helpers.RequestHelperV2 - 60,000 milliseconds timeout on connection http-outgoing-14 [ACTIVE]
java.net.SocketTimeoutException: 60,000 milliseconds timeout on connection http-outgoing-14 [ACTIVE]
at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.timeout(HttpAsyncRequestExecutor.java:381)
at org.apache.http.impl.nio.client.InternalIODispatch.onTimeout(InternalIODispatch.java:92)
2022-09-10 04:14:19,367 [TwitterProducer-scheduled-1] ERROR i.g.r.twitter.TwitterClient - Couldn't stopFilteredstream
java.util.concurrent.ExecutionException: java.net.SocketTimeoutException: 60,000 milliseconds timeout on connection http-outgoing-14 [ACTIVE]
at com.github.scribejava.httpclient.apache.OAuthAsyncCompletionHandler.getResult(OAuthAsyncCompletionHandler.java:95)
at com.github.scribejava.httpclient.apache.ApacheHttpFuture.get(ApacheHttpFuture.java:37)
at io.github.redouane59.twitter.TwitterClient.stopFilteredStream(TwitterClient.java:983)
at twitter2mastodon.worker.TwitterProducer.lambda$refreshWatch$47(TwitterProducer.java:657)
Caused by: java.net.SocketTimeoutException: 60,000 milliseconds timeout on connection http-outgoing-14 [ACTIVE]
at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.timeout(HttpAsyncRequestExecutor.java:381)
at org.apache.http.impl.nio.client.InternalIODispatch.onTimeout(InternalIODispatch.java:92)
I can put up a PR to add this later on.
Hey @takeshitakenji , yes that's a good point. I don't really master this topic because it was developed by someone else but if you feel that you can improve it, feel free to submit a pull request !
I can put up a PR to add this later on.
yes it would be perfect !