question

Upvotes
Accepted
1 1 0 0

Refinitiv Data Platform API connection error

Hello,
I am trying to establish python api connection to refinitiv dataplatform.

I have already installed refinitiv-dataplatform library for python (https://pypi.org/project/refinitiv-dataplatform/).

I am trying to establish connection throught following command:
rdp.open_platform_session( 'token', rdp.GrantPassword( 'user', 'password' ) )

Unfortunately, I gets following error in response: "2021-01-19 13:50:01,725 - Session session.platform - Thread 44920 | MainThread [Error -1 - ConnectError] b'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1123)'".

Could i kindly ask you to help me understand and solve this problem?


pythonrdp-apirefinitiv-data-platform
135838.png (44.4 KiB)
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
14.7k 39 12 18

Further update: I was able to get similar error when the library is used in conjunction with a proxy server which intercepts and re-sign's the https requests.

rdp.open_platform_session(appKey, rdp.GrantPassword(username = myuser, password = mypass))

2021-01-25 13:48:34,624 - Session session.platform - Thread 9916 | MainThread [Error -1 - SSLCertVerificationError] b'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get localissuer certificate (_ssl.c:1124)'

<refinitiv.dataplatform.core.session.platform_session.PlatformSession object at 0x00000000025A2760>


To alleviate this issue:

  • Are you able to connect without going through proxy server?
  • If not, do you have access to proxy's certificate?

Also, what is the result after you installed:

python-certifi-win32
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
11.7k 57 39 60

Hi @jaroslaw.szymanski,

This may be related to your environment. Can you please provide the following:

  • version of the refinitiv-dataplatform
  • version of the http dependencies: httpcore, httpx, requests
  • version of your desktop Eikon/Refinitiv Workspace
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
1 1 0 0

Thank you for your interest and additional questions.
Here are the versions of the relevant software:
refinitiv-dataplatform==1.0.0a7.post1
httpcore==0.10.2
httpx==0.14.3
requests==2.24.0
Eikon desktop 4.0.52 (4.0.52055)

Moreover, I forgot to mention this ealier, but I managed to establish connection via python API using following command:

rdp.open_desktop_session('token')

But as far as I know, this metod requires locally installed and actively running eikon software. That is why, I am looking for this second method of connection to be working.

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.

Thanks @jaroslaw.szymanski,

I matched your dependencies and did not see the same behavior. It's good you tested your desktop and that you are able to establish a connection. Because, you are connecting directly into the platform (not through the desktop), this will have no dependencies.

I'm in contact with the developer and will keep you updated.

thanks.

Upvote
11.7k 57 39 60

Hi @jaroslaw.szymanski,

We would like to capture some debugging information from you if that is ok. At the top of your code, can you insert this:

# to get trace from http lib
import os
os.environ['HTTPX_LOG_LEVEL']='trace'
os.environ['HTTPCORE_LOG_LEVEL']='trace'

This will generate output to the console. In addition, you should also see a log file created in your current directory. If you can also include the details from your log, stripping out any login credentials, if necessary.

thanks.

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
1 1 0 0

Above debugging code generated folowing output in my console:

TRACE [2021-01-20 11:01:21] httpx._config - load_ssl_context verify=True cert=None trust_env=True http2=False

TRACE [2021-01-20 11:01:21] httpx._config - load_verify_locations cafile=h:\python\lib\site-packages\certifi\cacert.pem

TRACE [2021-01-20 11:01:22] httpcore._async.connection_pool - get_connection_from_pool=(b'https', b'api.refinitiv.com', 443)

TRACE [2021-01-20 11:01:22] httpcore._async.connection_pool - created connection=<AsyncHTTPConnection http_version=UNKNOWN state=0>

TRACE [2021-01-20 11:01:22] httpcore._async.connection_pool - adding connection to pool=<AsyncHTTPConnection http_version=UNKNOWN state=0>

TRACE [2021-01-20 11:01:22] httpcore._async.connection - open_socket origin=(b'https', b'api.refinitiv.com', 443) timeout={'connect': 60, 'read': 60, 'write': 60, 'pool': 60}

TRACE [2021-01-20 11:01:22] httpcore._async.connection_pool - remove from pool connection=<AsyncHTTPConnection http_version=UNKNOWN state=5>

TRACE [2021-01-20 11:01:22] httpcore._async.connection_pool - removing connection from pool=<AsyncHTTPConnection http_version=UNKNOWN state=5>

2021-01-20 11:01:22,764 - Session session.platform - Thread 39868 | MainThread

[Error -1 - ConnectError] b'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1123)'

<refinitiv.dataplatform.core.session.platform_session.PlatformSession at 0x209d4e96520>

And this is the content of log file:

[2021-01-20 10:57:47,220] - [session.platform] - [ERROR] - [access_token_updater] - [_do_update] - [Error -1 - ConnectError] b'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1123)'
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.

Hi @jaroslaw.szymanski,

Thank you for the details - I will pass this off to the development team. One thing I forgot to ask, is what version of Python are you using?

thanks

I am using Python 3.8.5.

Hi @jaroslaw.szymanski,

Thank you. We're going through the list of dependencies as we believe there may be a conflict within. Can you provide the version of your 'nest-asyncio'? We are using version 1.3.3.

Show more comments
Upvotes
11.7k 57 39 60

Hi @jaroslaw.szymanski,

I'm working with development to better understand your situation. Given you are having no issues when you use the desktop session

rdp.open_desktop_session('token')

Is a good indication the http packages you have are not the issue. I tried to replicate your environment, making sure I'm using the same version of Python, and did not run into any issues.

While development believes the Python code, by default, doesn't take into account Windows certificates, they want you to try the following:

> pip install python-certifi-win32

This is based on the assumption that if you are using Windows and you have already imported the CA in the trusted DB store, you can install the package python-certifi-win32 that automagically will use the same certificates from the Trusted DB store.

https://pypi.org/project/python-certifi-win32/

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
14.7k 39 12 18

Hi @jaroslaw.szymanski,

Can you please confirm if you are going through a proxy server?

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.

I can only confirm, that I am using VPN connection.

What is the result after updating the python certificates - python-certifi-win32.

If all else fails, you might need to create a new python virtual environment and do a clean install of refinitiv-dataplatform library.

I think, that installing python-certifi-win32 nothing changed.

[2021-01-27 11:27:19,804] - [session.platform] - [ERROR] - [access_token_updater] - [_do_update] - [Error -1 - ConnectError] b'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1123)'

2021-01-27 11:27:19,804 - Session session.platform - Thread 38816 | MainThread [Error -1 - ConnectError] b'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1123)' 2021-01-27 11:27:19,804 - Session session.platform - Thread 38816 | MainThread [Error -1 - ConnectError] b'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1123)'

Show more comments