For a deeper look into our Elektron API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
13 6 5 4

Elektron Real Time in Cloud connection errors using Python and websocket.

Hello,

There is a following link, which helps retrieve data in Elektron https://github.com/Refinitiv/websocket-api/tree/master/Applications/Examples/RDP/python . Inside this folder are 2 python files. I am trying to run both of the codes however got the following error


Sending authentication request with password to https://api.refinitiv.com:15000/auth/oauth2/v1/token ...

EDP-GW authentication exception failure: HTTPSConnectionPool(host='api.refinitiv.com', port=15000): Max retries exceeded with url: /auth/oauth2/v1/token (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000001F4E99B9488>: 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'))


Process finished with exit code 1


I have set following variables:

# Global Default Variables
app_id = '256'
auth_url = 'https://api.refinitiv.com:443/auth/oauth2/v1/token'
hostname = '127.0.0.1'
password = 'PASSWORD WHEN REGISTER MACHINE ID'
position = ''
sts_token = ''
refresh_token = ''
user = 'MY EMAIL ADDRESS'
clientid = 'APP KEY VIA https://emea1.apps.cp.thomsonreuters.com/apps/AppkeyGenerator'
port = '443'
client_secret = ''
scope = 'trapi'
ric = '/TRI.N'
service = 'ELEKTRON_DD'


What should I do to retreive the market prices?

pythonelektronrefinitiv-realtimeelektron-sdkwebsockets
icon clock
10 |1500

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

Upvotes
Accepted
15.1k 28 8 12

Hello @g.suhharukov

Please be informed that the username for the Refinitiv Real-Time Optimized (formerly known as Elektron Real-Time in Cloud) should be a "machine id" (GE-XXXXXX..), not your email address. I suggest you contact your Refinitiv representative to help you get the machine id.


icon clock
10 |1500

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

@wasin.waeosri Yes, exactly. I just changed user to be a Machine ID and it seems it started connecting, however following error appeared

Sending authentication request with password to https://api.refinitiv.com:443/auth/oauth2/v1/token ...

EDP-GW Authentication succeeded. RECEIVED:

{

"access_token":"",

"expires_in":"300",

"refresh_token":"",

"scope":"trapi.auth.cloud-credentials trapi.cfs.claimcheck.read trapi.data.symbology.advanced.read trapi.data.symbology.read trapi.metadata.read trapi.streaming.pricing.read",

"token_type":"Bearer"

}

Connecting to WebSocket wss://127.0.0.1:443/WebSocket ...

[WinError 10061] No connection could be made because the target machine actively refused it

WebSocket Closed

Upvotes
7.6k 15 6 9

@g.suhharukov

From

Sending authentication request with password to https://api.refinitiv.com:15000/auth/oauth2/v1/token ... 

It looks like you have modified or set authentication host and port to override the default value, and it's the wrong one.

Auth URL should be below link as defined in the global default variable.

https://api.refinitiv.com:443/auth/oauth2/v1/token

What example are you using now? And What command-line argument are you using?

You can follow the instruction from the following quick-start guide to run the example.
https://developers.refinitiv.com/en/api-catalog/elektron/refinitiv-websocket-api/quick-start

icon clock
10 |1500

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

@moragodkrit.chumsri_1 Now I used

auth_url = 'https://api.refinitiv.com:443/auth/oauth2/v1/token' 
port = '443'

And the error is the same:

Sending authentication request with password to https://api.refinitiv.com:443/auth/oauth2/v1/token ...

EDP-GW authentication HTTP code: 400 Bad Request

@g.suhharukov

Does the api.refinitiv.com:443 is blocked on your site?

You can verify by using Postman example (RDP-> Authenticate -> Get Access Token, download here)

@wasin.waeosri Yes, when I put api.refinitiv.com:443 I am redirected to https://apidocs.refinitiv.com/Apps/ApiDocs and the red banner shows "Authentication failed:Error getting token". However when I run in Python it seems I got auth. token and new error authentication

Upvotes
7.6k 15 6 9

@g.suhharukov


400 Bad request is not the problem with the host. It seems to be the format of the request application sent.

  • Can you please restore the source codes to the original one and do not change any codes.

Then run the following command line and replaced Your RDP Username, Your RDP Password, and Client ID with your RDP login.


python.exe market_price_edpgw_service_discovery.py --user "<Your RDP Username>" --password "<Your RDP Password>" --clientid "Client ID"

icon clock
10 |1500

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

@moragodkrit.chumsri_1 I restored everything added Username, Password and Client ID. Additionally I added

hostname = '127.0.0.1'

because without it I got an error user, clientid, password, and hostname are required options. And when inserted these 4 things, I got the same error (described above)

[WinError 10061] No connection could be made because the target machine actively refused it

WebSocket Closed

Upvotes
13 6 5 4

I also found that in email sent By Reuters was written "python.exe market_price_edpgw_authentication.py --hostname emea-1.pricing.streaming.edp.thomsonreuters.com --user YourMachine --clientid YourMachine --password YourPassword"

So, I changed hostname to emea-1.pricing.streaming.edp.thomsonreuters.com, but it has the same issues as with previous hostname. Regarding "--user YourMachine --clientid YourMachine" I also tried different combinations such as app key + machine id, in both only machine id... and the same issue described below.

I now updated global variables and have the following errors:

In the file https://github.com/Refinitiv/websocket-api/blob/master/Applications/Examples/RDP/python/market_price_edpgw_authentication.py:

Connecting to WebSocket wss://127.0.0.1:443/WebSocket ...

[WinError 10061] No connection could be made because the target machine actively refused it

WebSocket Closed



And in the second file https://github.com/Refinitiv/websocket-api/blob/master/Applications/Examples/RDP/python/market_price_edpgw_service_discovery.py

Here I see, that it has not smth. As a result ,trying to refresh everything

SENT on session1:

{

"Type":"Pong"

}

RECEIVED on session1:

[

{

"Type":"Ping"

}

]

SENT on session1:

{

"Type":"Pong"

}

icon clock
10 |1500

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

Hello @g.suhharukov,

To re-iterate the info from @wasin.waeosri and @moragodkrit.chumsri_1, hostname = 127.0.0.1 will not work, as it is your local hostname, not ERT endpoint.

The latest version of example market_price_edpgw_authentication.py ,can be found at Websocket API -> Downloads, the mandatory parameters are:

--user, --clientid, --password, and --hostname.

I am testing from Americas region, my command line is:

python market_price_edpgw_authentication.py --hostname amer-1.pricing.streaming.edp.thomsonreuters.com --user MYMACHINEID --password MYLONGPASSWORD --clientid MYAPIKEY

If you are connecting from Europe, replace "amer-1" with "emea-1"

Hope this helps

Hello @g.suhharukov

Please try to run the example "as is" as suggested by my colleague @zoya.farberov.

I also strongly suggest you check the following WebSocket API resources which will give you a better detail of ERT in Cloud and WebSocket API: