question

Upvotes
Accepted
1 0 0 1

What is the best way to maintain websocket connection?

Hello,

I am trying to publish data to Elektron's websocket. Authorization token only lives for 10 minutes and when it expires, session is being closed. Before session expires I would like to start new session using refresh token. Once new session is ready my system would switch over to it and close previous session.


With this approach i am experiencing a bit inconsistent behaviour from the system. Sometimes when I issue login request for second session - first one gets closed.

I am attaching diagram of experienced behaviour.


session-extendingdrawio-1.png


I would appreciate any hints on how can I maintain websocket in such way so my system always have at least one active connection to publish data.


Regards,

Jan Roman

websockets
icon clock
10 |1500

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

Upvotes
Accepted
13k 32 12 18

Ok, in that case, you don't need to start a new websocket session. When the auth token is about to expire, you can proactively renew a new token and send it to the server. This way your existing connection will not be terminated.

See the python tutorial and associated example here.

icon clock
10 |1500

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

Upvote
13k 32 12 18

Hello @jan01,

Can you please elaborate on how you are trying to publish the data. Are you using Refinitiv Contributions Channel?

icon clock
10 |1500

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

Upvotes
1 0 0 1

Hi Gurpeet,

Thanks for getting back. Yeah I am using Refinitiv Contributions Channel using websocket connection to your cloud instance. For now I am using preproduction environment at endpoint: wss://contrib-ws1-emea1.uat.platform.refinitiv.com/WebSocket

I am using OAuth endpoint: https://api.ppe.refinitiv.com/auth/oauth2/v1/token

Regards,

Jan


icon clock
10 |1500

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

Click below to post an Idea Post Idea