I/O error on GET request for "https://api.twitter.com/1.1/statuses/user_timeline.json?count=20&include_entities=true":Operation timed out


#1

Hi,

I have written the following code:

public class Twitter1 {

    public static void m(){
    	String consumerKey ="XXXX"; // The application's consumer key
    	String consumerSecret ="XXXX"; // The application's consumer secret
    	String accessToken = "1138920258-XXXXX"; // The access token granted after OAuth authorization
    	String accessTokenSecret ="XXXXXX"; // The access token secret granted after OAuth authorization
        Twitter twitter = new TwitterTemplate(consumerKey, consumerSecret, accessToken, accessTokenSecret);
        List<Tweet> tweets = twitter.timelineOperations().getUserTimeline();
        Iterator<Tweet> i=tweets.iterator();
        while(i.hasNext()){
        	
            System.out.println(i.next().getText());
        }
        }
public static void main(String a[]){
    m();
}
    }

But I get the following error:
Exception in thread “main” org.springframework.web.client.ResourceAccessException: I/O error on GET request for “https://api.twitter.com/1.1/statuses/user_timeline.json?count=20&include_entities=true”:Operation timed out: connect:could be due to invalid address; nested exception is java.net.SocketException: Operation timed out: connect:could be due to invalid address
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:498)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:460)
at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:228)
at org.springframework.social.twitter.api.impl.TimelineTemplate.getUserTimeline(TimelineTemplate.java:69)
at org.springframework.social.twitter.api.impl.TimelineTemplate.getUserTimeline(TimelineTemplate.java:58)
at Twitter1.m(Twitter1.java:26)
at Twitter1.main(Twitter1.java:36)
Caused by: java.net.SocketException: Operation timed out: connect:could be due to invalid address
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:389)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:250)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:237)
at java.net.Socket.connect(Socket.java:543)
at java.net.Socket.connect(Socket.java:493)
at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:403)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:521)
at com.ibm.net.ssl.www2.protocol.https.b.(b.java:151)
at com.ibm.net.ssl.www2.protocol.https.b.a(b.java:156)
at com.ibm.net.ssl.www2.protocol.https.c.getNewHttpClient(c.java:5)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:774)
at com.ibm.net.ssl.www2.protocol.https.c.connect(c.java:47)
at com.ibm.net.ssl.www2.protocol.https.a.connect(a.java:61)
at org.springframework.http.client.SimpleBufferingClientHttpRequest.executeInternal(SimpleBufferingClientHttpRequest.java:73)
at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:46)
at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:49)
at org.springframework.http.client.InterceptingClientHttpRequest$RequestExecution.execute(InterceptingClientHttpRequest.java:91)
at org.springframework.social.oauth1.OAuth1RequestInterceptor.intercept(OAuth1RequestInterceptor.java:48)
at org.springframework.http.client.InterceptingClientHttpRequest$RequestExecution.execute(InterceptingClientHttpRequest.java:81)
at org.springframework.http.client.InterceptingClientHttpRequest.executeInternal(InterceptingClientHttpRequest.java:67)
at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:46)
at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:49)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:483)
… 6 more

Please help me how to progress with it .

Regards,
Neil


#2

Be careful never to share your API key and secrets on public forums.

Are you able to make any API calls to Twitter using the console on the same server? It sounds like you’re not able to access api.twitter.com. I would verify your network and DNS settings and try again.


#3

The code gives an error at this statement:
twitter.timelineOperations().getUserTimeline();
My workstation does use a proxy setting which is configured in the settings in eclipse. I tried opening google,twitter by typing the address in the address bar in the internal browser and it does work.
1)Do you think any manual proxy settings are needed?
2)Are there any other api calls I could test?
3)Is there any code I can use to check whether the proxy settings are working properly via java app.

Thanks for the privacy settings. :slight_smile:

And Thanks in advance for the help.

Regards,
Neil


#4

{
“ids”: [
385752029,
602890434,

333181469,
333165023
],
“next_cursor”: 1374004777531007833,
“next_cursor_str”: “1374004777531007833”,
“previous_cursor”: 0,
“previous_cursor_str”: “0”
}


#5

I am getting the exact same problem. Were you able to solve it?