Error with the code that uses Twitter4J API


#1

Hi, I’m working on a code that came with Twitter4J API which gets the Screen Name and Status of the any user on Twitter. I modified it to accept Screen Name as input. When i executed the following errors showed up on the output console.
connect timed outRelevant discussions can be on the Internet at:
http://www.google.co.jp/search?q=bb0a5eb5 or
http://www.google.co.jp/search?q=1e17b594
TwitterException{exceptionCode=[bb0a5eb5-1e17b594 5147af80-a4def8b3], statusCode=-1, retryAfter=-1, rateLimitStatus=null, featureSpecificRateLimitStatus=null, version=2.2.5}
at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:200)
at twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:65)
at twitter4j.internal.http.HttpClientWrapper.get(HttpClientWrapper.java:93)
at twitter4j.TwitterImpl.get(TwitterImpl.java:1878)
at twitter4j.TwitterImpl.showUser(TwitterImpl.java:486)
at ShowUser.main(ShowUser.java:51)
Caused by: java.net.SocketTimeoutException: connect timed out
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at sun.net.NetworkClient.doConnect(NetworkClient.java:158)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
at sun.net.www.http.HttpClient.(HttpClient.java:233)
at sun.net.www.http.HttpClient.New(HttpClient.java:306)
at sun.net.www.http.HttpClient.New(HttpClient.java:323)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:970)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:911)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:836)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1172)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379)
at twitter4j.internal.http.HttpResponseImpl.(HttpResponseImpl.java:35)
at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:164)
… 5 more
Failed to delete status: connect timed out

Is there anyone who can help me on this issue??? I’m new to this API and app development :slight_smile:


#2

I’m not particularly familiar with Twitter4J’s way of expressing errors, but the status code it is indicating, “-1” suggests to me that your connection isn’t reaching api.twitter.com at all, rather than it timing out on Twitter’s side.

I would verify that your machine is capable of connecting to Twitter through SSL by using curl on the command line to fetch a simple endpoint like:

curl -I "https://api.twitter.com/1/help/test.json"

If that works, then at least SSL and your network connectivity seem to be configured correctly and you can move on to Java environment-specific details.


#3

I am getting this error once I revoked permission from application.

07-08 12:19:47.980: W/System.err(4261): No authentication challenges found
07-08 12:19:47.980: W/System.err(4261): Relevant discussions can be found on the Internet at:
07-08 12:19:48.000: W/System.err(4261): http://www.google.co.jp/search?q=b2b52c28 or
07-08 12:19:48.000: W/System.err(4261): http://www.google.co.jp/search?q=10981ac7
07-08 12:19:48.015: W/System.err(4261): TwitterException{exceptionCode=[b2b52c28-10981ac7 4ef6906d-026b39df], statusCode=-1, message=null, code=-1, retryAfter=-1, rateLimitStatus=null, version=3.0.3}
07-08 12:19:48.070: W/System.err(4261): at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:192)
07-08 12:19:48.144: W/System.err(4261): at twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:61)
07-08 12:19:48.181: W/System.err(4261): at twitter4j.internal.http.HttpClientWrapper.post(HttpClientWrapper.java:98)
07-08 12:19:48.200: W/System.err(4261): at twitter4j.TwitterImpl.post(TwitterImpl.java:1871)
07-08 12:19:48.210: W/System.err(4261): at twitter4j.TwitterImpl.updateStatus(TwitterImpl.java:241)
07-08 12:19:48.221: W/System.err(4261): at com.objectlounge.ridesharebuddy.socialmedia.RS_Twitter.tweet(RS_Twitter.java:186)
07-08 12:19:48.244: W/System.err(4261): at com.objectlounge.ridesharebuddy.activities.RS_CreateTripActivity$PostOnSocialMedia.doInBackground(RS_CreateTripActivity.java:1369)
07-08 12:19:48.251: W/System.err(4261): at com.objectlounge.ridesharebuddy.activities.RS_CreateTripActivity$PostOnSocialMedia.doInBackground(RS_CreateTripActivity.java:1)
07-08 12:19:48.261: W/System.err(4261): at android.os.AsyncTask$2.call(AsyncTask.java:287)
07-08 12:19:48.271: W/System.err(4261): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
07-08 12:19:48.302: W/System.err(4261): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
07-08 12:19:48.310: W/System.err(4261): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
07-08 12:19:48.321: W/System.err(4261): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
07-08 12:19:48.330: W/System.err(4261): at java.lang.Thread.run(Thread.java:856)
07-08 12:19:48.351: W/System.err(4261): Caused by: java.io.IOException: No authentication challenges found
07-08 12:19:48.372: W/System.err(4261): at libcore.net.http.HttpURLConnectionImpl.getAuthorizationCredentials(HttpURLConnectionImpl.java:436)
07-08 12:19:48.380: W/System.err(4261): at libcore.net.http.HttpURLConnectionImpl.processAuthHeader(HttpURLConnectionImpl.java:416)
07-08 12:19:48.403: W/System.err(4261): at libcore.net.http.HttpURLConnectionImpl.processResponseHeaders(HttpURLConnectionImpl.java:365)
07-08 12:19:48.422: W/System.err(4261): at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:301)
07-08 12:19:48.432: W/System.err(4261): at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:495)
07-08 12:19:48.450: W/System.err(4261): at twitter4j.internal.http.HttpResponseImpl.(HttpResponseImpl.java:34)
07-08 12:19:48.490: W/System.err(4261): at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:156)


#4

Doing “curl -I “https://api.twitter.com/1/help/test.json””, I got this response.

HTTP/1.1 410 Gone
content-length: 160
content-type: application/json; charset=utf-8
date: Mon, 08 Jul 2013 07:09:43 UTC
server: tfe
set-cookie: guest_id=v1%3A137326738342994938; Domain=.twitter.com; Path=/; Expires=Wed, 08-Jul-2015 07:09:43 UTC
strict-transport-security: max-age=631138519

What does this mean?


#5

[dbadmin@smt-hadoop apache-flume-1.3.1-bin]$ curl -I "https://api.twitter.com/1/help/test.json"
curl: (7) couldn’t connect to host

Any idea, how to resolve this


#6

I also have the same problem using twitter 4j.
01-22 15:44:52.212: W/System.err(27444): oauth.signpost.exception.OAuthNotAuthorizedException: Authorization failed (server replied with a 401). This can happen if the consumer key was not correct or the signatures did not match.

so how do I resolve this issue?

Any suggestion welcome…


#7

i have the same problem can any one help me try from a week but still coludnt find the solution


#8

#9