question

Upvotes
Accepted
1 1 3 7

ConnectionError: - TRTH Rest API

HI, I am receiving the below error, while running the TRTH Rest API query for the tick history extraction. The first part is giving me the result. But the below code is throwing up the error - ConnectionError: HTTPSConnectionPool(host='s3.amazonaws.com', port=443): Max retries exceeded with url: /tickhistory.query.production.hdc-results/4878128CCEB3485887B68B8C1F66249B/data/merged/merged-Data.csv.gz?AWSAccessKeyId=AKIAJNJ6M4OJR7K3TWNA&Expires=1568374303&response-content-disposition=attachment%3B%20filename%3D_OnD_0x06c9cbb51910f51f.csv.gz&Signature=L3i%2F85avU6ngLDEz1pgNriYMYpk%3D (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x000000000E87CB70>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond',))

CODE -

requestUrl = "https://hosted.datascopeapi.reuters.com/RestApi/v1/Extractions/RawExtractionResults" + "('" + jobId + "')" + "/$value"


#AWS requires an additional header: X-Direct-Download

if useAws:

requestHeaders={

"Prefer":"respond-async",

"Content-Type":"text/plain",

"Accept-Encoding":"gzip",

"X-Direct-Download":"true",

"Authorization": "token " + token

}

else:

requestHeaders={

"Prefer":"respond-async",

"Content-Type":"text/plain",

"Accept-Encoding":"gzip",

"Authorization": "token " + token

}


r4 = requests.get(requestUrl,headers=requestHeaders)

I was able to run this before - have used this code extensively with modification. But recently I am getting the error. please help me to fix this.

tick-history-rest-api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

1 Answer

Upvote
Accepted
13.7k 26 8 12

@sreedhanya.kavunkara,

This looks like the TRTH_OnDemand_IntradayBars Python sample. I just ran it again, without issue.

I guess you set variable useAws = True, because the connection error is related to AWS, not the datascope server.

First set useAws = False, and run the entire code again. If this succeeds, it will prove that the issue is related to your connection to AWS.

  • A few queries that might help us find the cause of the issue you are facing:
  • Are you running into the error systematically, or only occasionally ?
  • Are you running from behind a firewall ?
  • Has anything changed in your network setup (running from a different machine, change in firewall or proxy settings, other ?).
  • Please run the following from a command window on the same machine: ping s3.amazonaws.com What is the result ?
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

@sreedhanya.kavunkara, have you made any progress on this issue ?

It worked when I modified the code by useAws = False. Thanks a lot. But one question- why it worked before and not working now. What is changed with Aws?

@sreedhanya.kavunkara, as far as I know nothing was changed on the AWS servers side. Maybe there was a change on a firewall that you are going through ? For more info on what this setting is for, see the article on Boosting your TRTH downloads using AWS.

Click below to post an Idea Post Idea