I have an fairly old twitter bot that's been running for several years no problem. It uses twitter4j, running on JRE 1.6. Two days ago I suddenly started getting SocketExceptions:
Exception in thread "main" Connection reset
Relevant discussions can be found on the Internet at:
http://www.google.co.jp/search?q=7e95ed42 or
http://www.google.co.jp/search?q=8a72206c
TwitterException{exceptionCode=[7e95ed42-8a72206c faf0771e-c3d1e8db], statusCode=-1, message=null, code=-1, retryAfter=-1, rateLimitStatus=null, version=4.0.7}
at twitter4j.HttpClientImpl.handleRequest(HttpClientImpl.java:185)
at twitter4j.HttpClientBase.request(HttpClientBase.java:57)
at twitter4j.HttpClientBase.get(HttpClientBase.java:75)
at twitter4j.TwitterImpl.get(TwitterImpl.java:2084)
at twitter4j.TwitterImpl.getFriendsList(TwitterImpl.java:808)
at twitter4j.TwitterImpl.getFriendsList(TwitterImpl.java:803)
at uk.co.twinance.Fetcher.getAvatars(Fetcher.java:167)
at uk.co.twinance.Fetcher.run(Fetcher.java:103)
at uk.co.twinance.Fetcher.main(Fetcher.java:203)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:168)
at com.sun.net.ssl.internal.ssl.InputRecord.readFully(InputRecord.java:422)
at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:460)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:863)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1188)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1215)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1199)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:434)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:166)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1195)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:318)
at twitter4j.HttpResponseImpl.<init>(HttpResponseImpl.java:35)
at twitter4j.HttpClientImpl.handleRequest(HttpClientImpl.java:149)
... 8 more
I get this on my linode and two home laptops running Ubuntu 11 and 18, and I get the Exception for every single request.
After much faffing I discovered that if I switch the runtime to JRE 11 it works flawlessly! No Exceptions at all.
So - i guess something on the twitter end has changed recently (given the issue is reproducible on 3 machines), but I am at a loss to understand how the JRE could be effecting network requests in a way that would cause a problem with twitter.
Any thoughts?