Unable to connect to the platform session in lseg

Alekya
Alekya Newcomer

Code:

import lseg.data as ld

ld.open_session(name="platform.ldp",config_name=r"C:\Users\alekyn\PycharmProjects\lseg-data.config.json")

Config File

{    "logs": {        "level": "debug",        "transports": {            "console": {                "enabled": false            },            "file": {                "enabled": false,                "name": "lseg-data-lib.log"            }        }    },    "sessions": {        "default": "platform.ldp",        "platform": {            "ldp": {                "signon_control": true,                "app-key": "*******",                "username": "

*",                "password": "*****"             },            "deployed": {                "app-key": "69afb7ce3c4f4cf0b7290c25eb77d5e7df2406dc",                "realtime-distribution-system": {                    "url" : "YOUR DEPLOYED HOST:PORT GOES HERE!",                    "dacs" : {                        "username" : "YOUR DACS ID GOES HERE!",                        "application-id" : 256,                        "position" : ""                    }                }            }        },        "desktop": {            "workspace": {                "app-key": "****"            }        }    }}

Error:
UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
An error occurred while requesting URL('https://api.refinitiv.com/auth/oauth2/v1/token').
ConnectTimeout('timed out')

Answers

  • Hi @Alekya ,

    Could you please try to increase the HTTP timeout in the configuration file, or run the code below before opening the session

    config = ld.get_config()config.set_param("http.request-timeout", 6000)
    
  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @Alekya

    It looks like to be a connection issue. You can use the following code to verify the connection.

    import requests
    
    url = "https://api.refinitiv.com/auth/oauth2/v1/token"
    
    payload = 'username=<username>&password=<password>&grant_type=password&scope=trapi&takeExclusiveSignOnControl=true&client_id=<appkey>'
    headers = {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
    
    response = requests.request("POST", url, headers=headers, data=payload)
    
    print(response.text)