Migration from Raw Websocket to Refinitiv Data Python

I have been using Refinitv Enterprise infrastructure to consume data using the raw websocket interface


The Login message I use in websocket interface is

{'ID': 2,

'Domain': 'Login',

'Key': {

'Name': MY_APP_ID USER,

'Elements': {

'ApplicationId': MY_APP_ID USER,

'Position': MY_IP}

}

}


As I am migrating to Refinitv Data Python library published in the Refinitiv API Portal, when I do the refinitive.data.open_session() I get what seems to be aun authentication error

These alternative options are already supported in the current version of the library.

[Error 401] - {'error': 'invalid_client', 'error_description': 'Invalid Application Credential.'}

Session is not opened. Can't send any request. The config file I use is the following one, where HOSTNAME:IP is exactily the same it is working in the websocket interface.


Both when choosing default set to platform.rdp or deployed, I get the problem.

Should I connect to other machine? the authentication method is different?

{

"logs": {

"level": "debug",

"transports": {

"console": {

"enabled": false

},

"file": {

"enabled": false,

"name": "refinitiv-data-lib.log"

}

}

},

"sessions": {

"default": "platform.rdp",

"platform": {

"rdp": {

"url" : "HOSTNAME:IP",

"app-key": "MY_APP_ID USER",

"username": "MY_APP_ID USER",

"password": "MY_APP_ID USER"

},

"deployed": {

"app-key": "YOUR APP KEY GOES HERE!",

"realtime-distribution-system": {

"url" : "HOSTNAME:IP",

"dacs" : {

"username" : "MY_APP_ID USER",

"application-id" : "MY_APP_ID USER",

"position" : ""

}

}

}

}

}

}

Best Answer

  • Jirapongse
    Answer ✓

    @vimontiel

    Thank you for reaching out to us.

    Accordin to the configuration, the default session is "platform.rdp". Therefore, if you don't specify it in the code, it will use this session which connects to Refinitiv Data Platform.

    To connection to RTDS, you need to use the "platform.deployed" session. Therefore, you can set the default session to "platform.deployed" or calling the rd.open_session("platform.deployed") method.

    Moreover, please make sure that you have configed the platform.deployed session correctly. For example:

    "deployed": {
            "app-key": "",
            "realtime-distribution-system": {
              "url": "127.0.0.1:15000",
              "dacs": {
                "username": "user01",
                "application-id": 256,
                "position": ""
              }
            }
          }

    Then, try the Streaming examples.

Answers

  • Thanks a lot for your response


    still getting same or similar response:

    ValueError: Cannot create auth manager, unknown grant type <class 'refinitiv.data._core.session.auth._null_grant.NullGrant'>


    URL should be localhost or the hostname I am using with websocket (which is where the Refinitive server is running on-prem)

    Either ways, I am getting the same authentication error that I dont get using raw Websocket interface


    thanks a lot

  • @vimontiel

    Please enable the debug log in the library and share the log file (refinitiv-data-lib.log).

    1715911059602.png

    Otherwise, you can enable it via the code. For example:

    config = rd.get_config()
    config.set_param("logs.transports.file.enabled", True)
    config.set_param("logs.transports.file.name", "refinitiv-data-lib.log")
    config.set_param("logs.level", "debug")
    rd.open_session("platform.deployed")
  • Hi,


    here you have


    I am wondering, could it be just an autentication error with DACS? in Websocket I would say I do not interact with DACS, but as per the example, seems to be expecting some DACS user. Not sure how authentication work for RDP and raw websocket interface, hope this helps


    [2024-05-17T10:26:42.072179+02:00] - [session] - [DEBUG] - [20588 - MainThread] - [_session] - [__init__] - Creating session "sessions.platform.deployed.0" based on session.platform.Definition("platform.deployed")
    [2024-05-17T10:26:42.076161+02:00] - [sessions.platform.deployed.0] - [DEBUG] - [20588 - MainThread] - [_platform_session] - [_connection] - Created session connection SessionCxnType.DEPLOYED
    [2024-05-17T10:26:42.076161+02:00] - [sessions.platform.deployed.0] - [DEBUG] - [20588 - MainThread] - [_session_provider] - [session_provider] - + Session created: PlatformSession
    name = 'deployed'
    connection = DeployedConnection
    stream_auto_reconnection = True
    deployed_server = HOSTNAME AND PORT WORKING FOR WEBSOCKET INTERFACE
    dacs_username = USERNAME WORKING FOR WEBSOCKET INTERFACE
    dacs_application_id = 256
    state = OpenState.Closed
    session_id = 0
    logger_name = sessions.platform.deployed.0

    [2024-05-17T10:26:42.086125+02:00] - [sessions.platform.deployed.0] - [DEBUG] - [20588 - MainThread] - [_session] - [open] - Open session
    [2024-05-17T10:26:42.106029+02:00] - [sessions.platform.deployed.0] - [DEBUG] - [20588 - MainThread] - [_session] - [open] - Opened session
  • @vimontiel

    According to the log, you can connect to the server.

    [2024-05-17T10:26:42.086125+02:00] - [sessions.platform.deployed.0] - [DEBUG] - [20588 - MainThread] - [_session] - [open] - Open session
    [2024-05-17T10:26:42.106029+02:00] - [sessions.platform.deployed.0] - [DEBUG] - [20588 - MainThread] - [_session] - [open] - Opened session

    Next, please try to run this example.

  • Thanks a lot


    tried and it works!!!. Seems to be working in streaming mode, but I do not want to use stream, instead I would prefer to use the synchronous API.


    Looking at other examples, I can do:

    eq_data = rd.get_data(['TEF.MC', 'BBVA.MC'])
    print(eq_data)

    eq_prices = rd.get_data(
    universe=['TEF.MC', 'BBVA.MC'],
    fields=['BID', 'ASK']
    )
    print(eq_prices)


    and seems to be working well.


    However the sample I have tried first with, as in the notebook:

    response = rd.content.pricing.Definition(['EUR='],fields=['BID', 'ASK']).get_data()
    print(response)

    keeps on returning that error (to be honest not sure what it means)

    ValueError: Cannot create auth manager, unknown grant type <class 'refinitiv.data._core.session.auth._null_grant.NullGrant'>


    Anyway I see connetivity is now OK, will play around with different connections following notebook

    thanks

    regards