question

Upvotes
Accepted
3 2 2 2

Python RDP Refresh token failed, response is None

Hi,
I'm using refinitiv-dataplatform 1.0.0a0 and trying to get real-time prices as a longrunning app (24/7).

But after 10 minutes I got

P[42662] [Thread-1 123145378373632] Refresh token failed, response is None
P[42662] [Thread-1 123145378373632] EDP Token Refresh failed : Refresh token request failed, response is None

I tried a trick described here with changing code in platform_session.py but nothing changed.

I also tried to add on_state and on_event but got

open_platform_session() got an unexpected keyword argument 'on_state'


How can I refresh the token for the current session?

My current code:

import refinitiv.dataplatform as rdp
import asyncio

rdp.open_platform_session(
    app_key,
    rdp.GrantPassword(
        machine_id,
        password
    )
)

print('Session ', rdp.get_default_session().get_open_state())

streaming_prices = rdp.StreamingPrices(
    universe=['EUR=', 'GBP=', 'JPY='],
    fields=['BID', 'ASK', 'VALUE_TS1'],
    on_refresh=lambda streaming_price, instrument_name, fields:
    display_refreshed_fields(streaming_price, instrument_name, fields),
    on_update=lambda streaming_price, instrument_name, fields:
    display_updated_fields(streaming_price, instrument_name, fields),
    on_status=lambda streaming_price, instrument_name, status:
    display_status(streaming_price, instrument_name, status),
    on_complete=lambda streaming_price:
    display_complete_snapshot(streaming_price)
)
streaming_prices.open()
while True:
    try:
        asyncio.get_event_loop().run_until_complete(asyncio.sleep(1))
    except (KeyboardInterrupt, SystemExit):
        rdp.close_session()
        break


rdp-apirefinitiv-data-platformrefinitiv-data-platform-libraries
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
7.6k 15 6 9

@Alena.Melnikova

I did a quick test with python3.6 and found a similar error but unable to see when running with 3.7.

Can you try the codes with Python 3.7 or 3.8?
I suspect that it might be the same issue mentioned in this post. It seems to be a problem with the conflict version of asycio lib but I can't confirm.

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
16.9k 32 9 12

Hello @Alena.Melnikova

What is the environment (Jupyter Notebook or Console) and Python version that you are using?

I am testing your code with Python 3.7.7 in Jupyter Notebook for an hour but I cannot replicate the issue in my environment yet.

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
7.6k 15 6 9

@Alena.Melnikova

I also tried your codes on Jupyter notebook but still not see issues as well. I can run for more than 1-2 hours. Note that I just print the fields out.

Do you have any chance to try your account with another example and did you found the token issue?

I'm not sure that is there any exception when you parse the field data so it interrupts the whole process?

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
3 2 2 2

Hi @moragodkrit and @Wasin Waeosri

Thanks for your responses!

I run in PyCharm with Python 3.6.8.

I also tried an example with rdp.ItemStream:

item_stream = rdp.ItemStream(
    session=session,
    domain='MarketByPrice',
    name="BB.TO",
    on_refresh=lambda item_stream, event: display_event("Refresh", event),
    on_update=lambda item_stream, event: display_event("Update", event),
    on_status=lambda item_stream, event: display_event("Status", event),
    on_complete=lambda item_stream: display_event("Complete", "")
)

item_stream.open()
while True:
    try:
        asyncio.get_event_loop().run_until_complete(asyncio.sleep(1))
    except (KeyboardInterrupt, SystemExit):
        rdp.close_session()
        break

and get the same issue in 9 minutes after start script:

>>> Status event received at 18:54:01.305752
{'status': <StreamState.Open: 3>, 'code': 'Open', 'message': '*All is well'}
...

>>> Update event received at 19:01:09.665777
{'ID': 1, 'Type': 'Update', 'Domain': 'MarketByPrice', 'UpdateType': 'Unspecified', 'Key': {'Service': 'ELEKTRON_DD', 'Name': 'BB.TO'}, 'SeqNumber': 61888, 'Map': {'KeyType': 'Buffer', 'Summary': {'Fields': {'TIMACT_MS': 39669358}}, 'Entries': [{'Action': 'Update', 'Key': 'NS45NTAwMDBC', 'Fields': {'ORDER_PRC': 5.95, 'ORDER_SIDE': 'BID', 'ACC_SIZE': 200, 'NO_ORD': 2, 'LV_TIM_MS': 39669358, 'LV_TIM_MSP': 80, 'LV_DATE': '2020-08-06'}}]}}
2020-08-06 19:02:57,172 P[47654] [Thread-1 123145384079360] Refresh token failed, response is None
2020-08-06 19:02:57,174 P[47654] [Thread-1 123145384079360] EDP Token Refresh failed : Refresh token request failed, response is None
2020-08-06 19:12:01,878 P[47654] [Thread-1 123145384079360] Refresh token failed, response is None
2020-08-06 19:12:01,881 P[47654] [Thread-1 123145384079360] EDP Token Refresh failed : Refresh token request failed, response is None
2020-08-06 19:21:06,236 P[47654] [Thread-1 123145384079360] Refresh token failed, response is None
2020-08-06 19:21:06,237 P[47654] [Thread-1 123145384079360] EDP Token Refresh failed : Refresh token request failed, response is None

There is nothing special in parsing data. Just print it:

def display_event(eventType, event):
    currentTime = datetime.datetime.now().time()
    print("----------------------------------------------------------")
    print(">>> {} event received at {}".format(eventType, currentTime))
    print(event)
    return

Can it be a problem with my account? I use a machine account.

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
3 2 2 2

@moragodkrit You're right! I tried Python 3.7 and it works without intervention 3 hours already! Thank you!

I also noticed that I can't run one more app in parallel. In a few minutes, the first app failed with error

[Error 400 - access_denied] iPlanet session has been expired. 

Even if I use different app_key. Does it mean I can't run a few apps for one account?

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 @Alena.Melnikova

Please be inform that the platform allow one machine-id login at a time only , so you cannot use the same machine-id to connects to ERT in Cloud simultaneously (even using different app_key/client_id).

got it! Thank you!