RDP websocket Exception

Hi, I am running a multithreaded C# application which subscribes to pricestream and also getting some reference data. I having this exception caught at run time : System.Net.WebSockets.WebSocketException: 'The WebSocket is in an invalid state ('Aborted') for this operation. Valid states are: 'Open, CloseReceived''
Please can you help solve this ?
Mahmoud.
Best Answer
-
hI @melarbi,
The default WebSocket implementation within the library uses Microsoft's WebSocketClient which does behave in the following manner:
- Attempting to invoke any other operations in parallel may corrupt the instance. Attempting to invoke a send operation while another is in progress or a receive operation while another is in progress will result in an exception.
As a result, if you attempt to call AddItems() from different threads, you may run into the issue above. The library does offer the ability to use a different WebSocket implementation - as stated in the above answers. Different libraries may allow for simultaneous access.
Alternatively, you can apply your own thread synchronization to the AddItems() call to ensure it completes before another thread attempts to access.
0
Answers
-
Hi @melarbi,
Did you write this application from scratch using a public WebSocket API based on example code? Or did you use the community based RDP Library for .Net?
It would be helpful to understand where you started from as applications written against RDP require token refresh on both the gateway as well as the connection into the real-time streaming services.
0 -
Hi @nick.zincone.1. I am using the example code from RDP Library .NET examples and I am changing it to my needs. The list of names for which I create a "subscription" is dynamic and changes through the day. Initial subscription list is created at start up then new RICs are added to the stream ( stream.AddItems ( "RIC-NEW") ) using a blocking call.
0 -
Thanks @melarbi,
As you can imagine, I can't do much without a code sample that demonstrates the issue. Does the error occur systematically? That is, can you reproduce it every time? Is it random? Where/what are you specifically doing that is causing the issue? You mentioned it is multi-threaded - what are the different threads doing? Are they both calling into the API?
thanks.
0 -
Hi @melarbi,
The RDP Library for .Net uses 3rd party WebSocket libraries. In addition, the library has the ability to implement its own WebSocket implementation.
Within the example package, 3.0.03-Core-WebSocket provides the way for users to choose different WebSocket implementations. In addition, that example also implements code for another 3rd WebSocket library and how to register it with the library.
It is quite possible the WebSocket library you are using may have issues. If you can systematically recreate the issue, I would suggest registering a different implementation to see if this helps.
0 -
It sounds like currently, you have added more complex codes on top of the example. It is quite hard to tell for possible issues because we do not have sample codes and don't know your apps' actual implementation.
From the latest version of RDPLibrary for .NET, you can choose the different WebSocket library(ClientWebsocket, WebsocketSharp, Websocket4net).
Not sure which one is the Websocket Library your application is using?
If the problem always occurs when you run the app. Can you change Logger to Trace level by setting
Log.Level = NLog.LogLevel.Trace;
at the begging of the app.
It usually creates RDPLog_<pid>.log under the running directory. Perhaps the log may contain some error that helps pinpoint the possible root cause.
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 37 Alpha
- 167 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 710 Datastream
- 1.5K DSS
- 637 Eikon COM
- 5.3K Eikon Data APIs
- 18 Electronic Trading
- 1 Generic FIX
- 7 Local Bank Node API
- 10 Trading API
- 3K Elektron
- 1.5K EMA
- 260 ETA
- 571 WebSocket API
- 42 FX Venues
- 16 FX Market Data
- 2 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 26 Messenger Bot
- 4 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 284 Open PermID
- 47 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 25 RDMS
- 2.3K Refinitiv Data Platform
- 17 CFS Bulk File/TM3
- 928 Refinitiv Data Platform Libraries
- 5 LSEG Due Diligence
- 1 LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 46 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 27 DACS Station
- 126 Open DACS
- 1.1K RFA
- 108 UPA
- 197 TREP Infrastructure
- 232 TRKD
- 924 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 106 Workspace SDK
- 11 Element Framework
- 5 Grid
- 19 World-Check Data File
- 1 Yield Book Analytics
- 48 中文论坛