Error connection timed out


#1

Recently, this bug happen everyday. If I re-run, sometime it is can be successful, sometime it returns the same error.
Sometime, 1 account_id always return connection time out error although I re-run many times. I try another account_id, it is still good. So, why?

I want to ask the reason why it happen every day. Is that any way to reduce this bug.

This bug happen when I get list of scoped_timeline.

GET accounts/:account_id/scoped_timeline
Reference link: https://developer.twitter.com/en/docs/ads/creatives/api-reference/tweets

The error content is:

Caused by: org.apache.http.conn.HttpHostConnectException: Connect to ads-api.twitter.com:443 [ads-api.twitter.com/104.244.42.195] failed: Connection timed out (Connection timed out)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:159)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:359)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)

Caused by: java.net.ConnectException: Connection timed out (Connection timed out)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:339)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)


#2

Hi @dudoan1234,

In order for me to recreate and investigate the issue you are seeing. Can you please use twurl to execute the endpoint and copy/paste the request and response below? Thanks!

$ twurl -H ads-api.twitter.com "/2/accounts/18ce5475gij/scoped_timeline?scoped_to=none" | jq
{
  "data": [
    {
      "created_at": "Fri Sep 29 21:09:52 +0000 2017",
      "id": 913873484375253000,
      "id_str": "913873484375252992",
      "text": "https://t.co/pDFTBRdrm1 https://t.co/fg74Nx2XmD",
      "truncated": false,
      "entities": {
        "hashtags": [],
        "symbols": [],
        "user_mentions": [],

#3

Thank for trying to help me. I found the problem in my source code. It is not problem of API. So, I will close this question here. Anyway, thank you very much.