Getting Connection Times Out in the subsequent rest api call for DSS

ratan
ratan Newcomer

Hi @zoya

I am able to get the auth token successfully ,however when doing the next call getting the below error.

I am connecting using proxy .Please help.

Session Token (expires in 24 hours):
_wQUWnpA0Ep7Nol3I8BOUDbpESHAHfHhDydLqnS0CoOYx_4lWUrxUG8qX4wRjOPJri-ET30v8p1wf56BaaYCAsOJBaY353K0M7CMHFlbvdoJoES0O8PIxcwrfIf-SV8EAKAnXexa28DXbwc5L7qaWNpiJLWUgBKiJ44S3dYubg5ADITl0CHrz4TZrn7-Dfw4c9eSF1AFTxw_sEV0w-GNl_wU5q7OijCCepEBs-iczwG_Xr8pxP1zVtFd4qWJm1jIW3ngZVMWQCFar93d50UOXXgmnh58wf8apB9UUjOu3Isk
Instrument list creation JSON request content:
@{"@odata.type":"#ThomsonReuters.Dss.Api.Extractions.SubjectLists.InstrumentList","Name":"Demo_TermsAndCondition_Instrumentslist"}
org.apache.http.conn.HttpHostConnectException: Connect to hosted.datascopeapi.reuters.com:443 [hosted.datascopeapi.reuters.com/192.165.219.152] failed: Connection timed out: connect
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)
Press "ENTER" to continue...

Best Answer

  • zoya faberov
    zoya faberov ✭✭✭✭✭
    Answer ✓

    Hello @rattan,

    I'd like to confirm that:

    Your token is less then 24 hours old and is valid

    You are yusing proxy info for the second request same as for the token request, as in Java examples on this portal, i.e.:

      // Set proxy information for HTTP Components

    HttpHost proxy = new HttpHost(proxyHostName, proxyPortNumber);

    DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy);

    CloseableHttpClient httpclient = HttpClients.custom()

    .setRoutePlanner(routePlanner)

    .build();

    If that is the case;

    I would try testing another request, maybe run one of our Java request examples so you don't have to write custom code for this test:

    TRTH REST Java Code Examples

    Or, are you familiar with CURL, can you test with curl passing your proxy parameter at the end:

       --proxy your_proxy:your_port

Answers

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    Please try to set connection timeout in the code.

        private int timeout=30;
    private RequestConfig config = RequestConfig.custom()
    .setConnectTimeout( timeout * 1000)
    .setConnectionRequestTimeout(timeout * 1000)
    .setSocketTimeout(timeout * 1000).build();
    private CloseableHttpClient httpclient = HttpClientBuilder.create().setDefaultRequestConfig(config).disableContentCompression().build();

    I found this code at http://www.baeldung.com/httpclient-timeout.

  • ratan
    ratan Newcomer

    Thank you for this code for setting up the timeout.i have set the timeout in my code ,however it's still giving me the same error.Is there any setting needs to be done other than this.

    And also i am able to fetch the authToken successfully ,but next call is not able to make connection.Please suggest.

    Session Token (expires in 24 hours):
    _lsR9iGnIr1NHvGagAivokEhVlambBzqa_SlI4QfmNkxj7bmXn2gQuE3boqOo7rG_-C3A9ERoPFFP7SywX_LMIET1vLX-lBjjP3Nbi_RawJsabVkW51x0Avs745uSSAKnLyf90E-rFsTXheCYhc-QPqs2qwGMdK1M5e5PCtw9ZjjzykUXW1Q7eHBqAxyYXUpBqt93eniNyHWrRDNPIsnP4704qyFyJicF9tKbhW2Gi6tb6Qtup2YQGGwPVFareXBcYmCxzzV0V1HyystNZFHdy1EmE7FJZOocKUmp-FGUiRs
    https://hosted.datascopeapi.reuters.com/RestApi/v1/Extractions/Schedules
    _lsR9iGnIr1NHvGagAivokEhVlambBzqa_SlI4QfmNkxj7bmXn2gQuE3boqOo7rG_-C3A9ERoPFFP7SywX_LMIET1vLX-lBjjP3Nbi_RawJsabVkW51x0Avs745uSSAKnLyf90E-rFsTXheCYhc-QPqs2qwGMdK1M5e5PCtw9ZjjzykUXW1Q7eHBqAxyYXUpBqt93eniNyHWrRDNPIsnP4704qyFyJicF9tKbhW2Gi6tb6Qtup2YQGGwPVFareXBcYmCxzzV0V1HyystNZFHdy1EmE7FJZOocKUmp-FGUiRs
    org.apache.http.conn.HttpHostConnectException: Connect to hosted.datascopeapi.reuters.com:443 [hosted.datascopeapi.reuters.com/192.165.219.152] failed: Connection timed out: connect
    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)

  • ratan
    ratan Newcomer

    Thank you Zoya.I am able to make successful rest calls.

    Thanks

    Ratan