[OMMSTREAMING_PRICING_0.12] received a closing message (cxn state=StreamCxnState.Connected, message
Hi Developers Community
I am running a Refinitiv web socket client, testing if it can consistently accept market data "forever"? after some long time connection is closed with error message:
[Error 400 - invalid_grant] empty error description
[OMMSTREAMING_PRICING_0.12] received a closing message (cxn state=StreamCxnState.Connected, message state={'Stream': 'Closed', 'Data': 'Suspect', 'Code': 'UserAccessToAppDenied', 'Text': 'TREP authentication failed (1026, Request for token validation failed:Authentication server did not contain "active" in response).'})
how to prevent Refinitiv connection from disconnecting while running a web socket infinitely (suppose to never stop getting market data feed)?
Thanks
Ori
Best Answer
-
First, you can update the application to use the new version of RD Library (refinitiv-data 1.0.0b13). Then, enable debug logging in the refinitiv-data.config.json file.
"logs": {
"level": "debug",
"transports": {
"console": {
"enabled": false
},
"file": {
"enabled": true,
"name": "refinitiv-data-lib.log"
}
}
},
"sessions": {Next, share the log file when the problem occurred. Please remove the RDP credential (username and password) from the log file.
One scenario that can trigger this issue is that many applications share the same RDP credential at the same time. An RDP credential can only have one active refresh token at a time. For more information, please refer to the Limitations and Guidelines for the RDP Authentication Service article.
For example, when the first application logs in to RDP, it will get both an access and a refresh token. A fresh token will be used to get a new access token. However, if the second application logs in with the same RDP credential, the previous refresh token in the first application will be invalidated and the first application is unable to use it to get a new access token. You will see this kind of error in the log file of the first application.
[2022-06-02 09:14:41,790] - [sessions.platform.rdp.0] - [DEBUG] - [10920 - AuthManager-Thread] - [http_service] - [request] - HTTP request response 400: {"error":"invalid_grant" }
[2022-06-02 09:14:41,791] - [sessions.platform.rdp.0] - [DEBUG] - [10920 - AuthManager-Thread] - [refresh_token_updater] - [_request_token] - Refresh token response: {"error":"invalid_grant" }
[2022-06-02 09:14:41,791] - [sessions.platform.rdp.0] - [ERROR] - [10920 - AuthManager-Thread] - [refresh_token_updater] - [_do_update] - [Error 400 - invalid_grant] empty error description
[2022-06-02 09:14:41,791] - [sessions.platform.rdp.0] - [DEBUG] - [10920 - AuthManager-Thread] - [auth_manager] - [_refresh_token_update_handler] - AuthManager: Refresh token handler, event: refresh_token_bad, message: empty error description
[2022-06-02 09:14:41,791] - [sessions.platform.rdp.0] - [DEBUG] - [10920 - AuthManager-Thread] - [_session] - [_on_event] - Session._on_event(event_code=EventCode.SessionAuthenticationFailed, event_msg=empty error description, streaming_session_id=None, stream_connection_name=None)
[2022-06-02 09:14:41,791] - [sessions.platform.rdp.0] - [DEBUG] - [10920 - AuthManager-Thread] - [auth_manager] - [close] - AuthManager: closeThen, you will the following error.
[2022-06-02 09:20:14,585] - [sessions.platform.rdp.0] - [DEBUG] - [12348 - ThreadOMMSTREAMING_PRICING_0.5] - [stream_connection] - [_on_ws_error] - [OMMSTREAMING_PRICING_0.5] on_ws_error
[2022-06-02 09:20:14,585] - [sessions.platform.rdp.0] - [DEBUG] - [12348 - ThreadOMMSTREAMING_PRICING_0.5] - [stream_connection] - [_on_ws_error] - [OMMSTREAMING_PRICING_0.5] Exception: Connection to remote host was lost.
[2022-06-02 09:20:14,585] - [sessions.platform.rdp.0] - [DEBUG] - [12348 - ThreadOMMSTREAMING_PRICING_0.5] - [stream_connection] - [_on_ws_close] - [OMMSTREAMING_PRICING_0.5] on_ws_close (close_status_code=None, close_msg=None)
[2022-06-02 09:20:14,585] - [sessions.platform.rdp.0] - [DEBUG] - [12348 - ThreadOMMSTREAMING_PRICING_0.5] - [stream_connection] - [_on_ws_close] - [OMMSTREAMING_PRICING_0.5] try to reconnect over url wss://ap-southeast-1-aws-3-lrg.optimized-pricing-api.refinitiv.net:443/WebSocket in 5 secs, number of reconnections is 1, StreamCxnState.Reconnecting
[2022-06-02 09:20:19,596] - [sessions.platform.rdp.0] - [DEBUG] - [12348 - ThreadOMMSTREAMING_PRICING_0.5] - [stream_connection] - [connect] - [OMMSTREAMING_PRICING_0.5] is connecting [con]
[2022-06-02 09:20:19,596] - [sessions.platform.rdp.0] - [DEBUG] - [12348 - ThreadOMMSTREAMING_PRICING_0.5] - [stream_connection] - [connect] - [OMMSTREAMING_PRICING_0.5] connect (
num_connect=1,
url=wss://ap-southeast-1-aws-3-lrg.optimized-pricing-api.refinitiv.net:443/WebSocket,
headers=['User-Agent: Python'],
subprotocols=['tr_json2'])
[2022-06-02 09:20:20,445] - [sessions.platform.rdp.0] - [DEBUG] - [12348 - ThreadOMMSTREAMING_PRICING_0.5] - [stream_connection] - [_on_ws_open] - [OMMSTREAMING_PRICING_0.5] connected [CON]
[2022-06-02 09:20:20,445] - [sessions.platform.rdp.0] - [DEBUG] - [12348 - ThreadOMMSTREAMING_PRICING_0.5] - [stream_connection] - [_on_ws_open] - [OMMSTREAMING_PRICING_0.5] on_ws_open
[2022-06-02 09:20:20,445] - [sessions.platform.rdp.0] - [DEBUG] - [12348 - ThreadOMMSTREAMING_PRICING_0.5] - [stream_connection] - [send] - [OMMSTREAMING_PRICING_0.5] send s={"Domain": "Login", "ID": 5, "Key": {"NameType": "AuthnToken", "Elements": {"AuthenticationToken": "...", "ApplicationId": "256", "Position": "192.168.0.184/WIN-2NOVD7CLMV1"}}}
[2022-06-02 09:20:20,885] - [sessions.platform.rdp.0] - [DEBUG] - [12348 - ThreadOMMSTREAMING_PRICING_0.5] - [stream_connection] - [_on_ws_message] - [OMMSTREAMING_PRICING_0.5] on_ws_message [{"ID":5,"Type":"Status","Domain":"Login","Key":{"NameType":5,"Elements":{"AuthenticationErrorCode":1026,"AuthenticationErrorText":"Request for token validation failed:Authentication server did not contain \"active\" in response"}},"State":{"Stream":"Closed","Data":"Suspect","Code":"UserAccessToAppDenied","Text":"TREP authentication failed (1026, Request for token validation failed:Authentication server did not contain \"active\" in response)."}}]
[2022-06-02 09:20:20,885] - [sessions.platform.rdp.0] - [ERROR] - [12348 - ThreadOMMSTREAMING_PRICING_0.5] - [omm_stream_connection] - [_handle_login_message] - [OMMSTREAMING_PRICING_0.5] received a closing message (cxn state=StreamCxnState.Connected, message state={'Stream': 'Closed', 'Data': 'Suspect', 'Code': 'UserAccessToAppDenied', 'Text': 'TREP authentication failed (1026, Request for token validation failed:Authentication server did not contain "active" in response).'})
[2022-06-02 09:20:20,885] - [sessions.platform.rdp.0] - [DEBUG] - [12348 - ThreadOMMSTREAMING_PRICING_0.5] - [stream_connection] - [dispose] - [OMMSTREAMING_PRICING_0.5] is disposing [d]
[2022-06-02 09:20:20,885] - [sessions.platform.rdp.0] - [DEBUG] - [12348 - ThreadOMMSTREAMING_PRICING_0.5] - [stream_connection] - [send] - [OMMSTREAMING_PRICING_0.5] send s={"Domain": "Login", "ID": 5, "Type": "Close"}0
Answers
-
Hello @okatz
This "TREP authentication failed (1026, Request for token validation failed:Authentication server did not contain \"active\" in response)." error message is generated from the RTO WebSocket server when it receives an expired Access Token in the WebSocket JSON login request message from the application.
Does the application send an active (and valid) Access Token to the RTO server?
Please note that the Access Token always expires in 600 seconds (based on the RDP Auth response’s “expires_in” JSON value). The application needs to maintain the Access Token session and WebSocket connection with the following steps:
- renew the Access Token by sending the HTTP REST request to the RDP Auth service (with "refresh_token" grant type) to get a new refresh and Access Tokens before the Access Token expires.
- Re-send a Login request to the Refinitiv Real-Time - Optimized server using the new obtained Access Token
You can find more detail on the Connect to Refinitiv Real-Time - Optimized tutorial page. The example code that shows a connection logic is available for Java, C#, and Python programming languages at https://github.com/Refinitiv/websocket-api/tree/master/Applications/Examples/RDP page (please ignore the Go example, it is for a different logic).
1 -
Hello @okatz
I am suspecting that you are using the Refinitiv Data Library (RD) ease-of-use API, please confirm my understanding.
If you are using the RD library, can you give us more detail?
- Which library edition you are using (Python or .Net)?
- The library and compiler versions
- Can you replicate the issue with the library example?
0 -
import refinitiv.data as rd
from refinitiv.data.content import pricingpython version on development windows 10 workstation:
(py38q) E:\workQuant\MRMTFeedRT>python -V
Python 3.8.12
refinitiv-data 1.0.0b10and with production ubuntu 20.04 server:
(base) ori_kovacsi_katz@prod:~$ conda activate kx1
(kx1) ori_kovacsi_katz@prod:~$ python -V
Python 3.9.7
(kx1) ori_kovacsi_katz@prod:~$refinitiv-data 1.0.0b9
connecting client:
rd.load_config('E:/Configuration/refinitiv-data.config.json')
#rd.load_config('/Configuration/refinitiv-data.config.json')
rd.open_session()
self.theWebSocket = rd.content.pricing.Definition(['BTCc1','BTCc2','BTCc3','BTCc4','BTCc5','BTCc6','BTCc7','BTCc8','BTCc9','QBTCu.TO','QETHu.TO'], fields=['BID', 'ASK', 'QUOTIM', 'QUOTIM_MS', 'ORDER_SIDE', 'ORDER_PRC', 'ORDER_SIZE', 'BID_SIZE', 'ASK_SIZE']).get_stream()
self.theWebSocket.on_refresh(self.handle_refresh)
self.theWebSocket.on_update(self.handle_update_wrapper)
self.theWebSocket.on_status(self.handle_status)
self.theWebSocket.open()0 -
I could not find a simple explanation how to handle and refresh expiration token when working with web sockets. Examples are with HTTP. I try to reduce footprint of additional libraries and http/s coding. Is there a simple method to just refresh the token before expiration without too match integration and coding?0
-
Hello @okatz
Just want to add more information to my colleague's answer about multiple applications sharing the same RDP credential.
If you use a single RDP credential with multiple sessions/applications, the applications may encounter an error when an access token expires or when applications try to refresh an access token (as explained by my colleague above). I suggest you use multiple credentials if you want to run multiple applications/sessions.
0
Categories
- All Categories
- 6 AHS
- 37 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 59 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛