question

Upvotes
Accepted
1 0 1 1

Refinitiv web socket connection issue

Hello, has anyone come across below issues:

1) Sometimes websocket connection is not establishing

2) Sometimes there is no response from Refinitiv

How to solve this issue?

refinitiv-realtime#productwebsockets
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
26.3k 61 17 14

Hello @techlead @Bhavik

Could you please clarify the "We are generating a new access token every 5 seconds" message? Why does the application refresh token every 5 seconds?

It would be nice if you can post a cutdown version of your code that can replicate the issue to let us check in detail.

### RTO Access Token time ###

The Access Token expiration time is based on the "expires_in" information value. The default expires_in is 600 seconds (10 minutes), so the application should refresh a token with RDP and re-send a new access token to the WebSocket server every 90% of the initial time before it expires (aka 9 minutes), not every 5 seconds.

### RTO Workflow ###

Please let me explain more about the RTO WebSocket connection workflow. The WebSocket - RTO connection workflow is a mix of the RDP APIs HTTP and WebSocket API workflows. The workflow summaries are as follows.

  1. Send an HTTP Post message with a Password Grant credential (grant_type=password) to the RDP API Authentication service (http://api.refinitiv.com/auth/oauth2/v1/token URL) and obtain an access token, refresh token, and session expiration interval for your application.
  2. Then requests the list of the RTO streaming server endpoints with the RDP APIs Pricing service (https://api.refinitiv.com/streaming/pricing/v1/) via HTTP request
  3. Establish a WebSocket connection to the desired RTO WebSocket server.
  4. Once the application receives a connection confirmation via the on-connect callback method, send a JSON login message to the WS server with an access token.
  5. Once the application receives a login refresh message from the WS server, the application can start a data flow such as requesting data
  6. Re-authenticate with RDP API Authentication using a Refresh Grant credential (grant_type=refresh_token) before token expiration (“expires_in” seconds) to get a new token
  7. Re-send a JSON login request with a new access token to the WS server before token expiration to keep the session open.
  8. Repeat steps (6) and (7) before the “expires_in” time exceed
  9. The WebSocket server periodically sends a ping message to the consumer as a heartbeat message, the application needs to send a pong message back

rto-api-flow.png

You can see more detail on the RTO Python market_price_rdpgw_service_discovery.py example (the code is in Python, but the concept is the same for all languages).

I strongly suggest the client read the WebSocket API: Connect to Refinitiv Real-Time - Optimized tutorial.

There is the Article.WebSocketAPI.Javascript.QuoteWidget and Example.ERT.Javascript.ERTController JavaScript examples for RTO (and RTDS) that you can check the workflow above with JavaScript code.

  • Note: the code is for demonstration purposes only, not for Production use

rto-api-flow.png (64.9 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
26.3k 61 17 14

Hello @techlead

I am sorry to hear that you are facing those issues. Are you connecting to your local RTDS or RTO? Can you replicate the issue on demand with the WebSocket API examples?

About the "Sometimes there is no response from Refinitiv", the WebSocket API is a server-side API, so you may need to contact the server team to verify the issue on the server side. I highly recommend you contact the Real-Time support team from https://my.refinitiv.com/content/mytr/en/helpandsupport.html website.

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,

Posting on behalf of @techlead

Hi @wasin.w - client is using RTO and there is a case 12669770 open with platform support who are unable to see disconnection. the last error on the case is - "Undefined data issue was from our end. We are generating a new token every 5 seconds and after some random duration the websocket connection is not established."

Below is a snippet of the comms with support after 10-July.

Platform support:

I cross referenced your logs with our logs on the backend. But I do not see any disconnections.

Have you implemented the 4 minute refresh logic? Did it resolve the undefined data retreival?

Client:

We tried the solution specified by you, but the same issue persists. We are generating a new access token every 5 seconds then too after 8-10 minutes our connection is getting lost and we are unable to connect to websocket again.

Wasim, need your assistance on the same topic.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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