Price streaming using platform session showing inconsistent behaviour

Application: AlphaDesk connecting via Refinitiv Data .Net Library using a PlatformSession
Issue: Subscribing to the same set of ticker/fields is showing inconsistent behaviour. One of the following 3 scenarios occur (in likelihood order):
- Streams for pricing are successfully connected and receive refresh/updates
- The price streaming seemingly stops working at some point during startup. Some prices were retrieved but don't refresh anymore
- The connection disconnects and warns "Retrying in 15 seconds", after the 15 seconds it reconnects and prices are retrieved and update
The largest concern is regarding the second scenario as the application does not receive any price updates.
Notes:
- For scenario 2, the connection seems to die around the point where we're receiving "access denied" msgs for some tickers - we resubscribe to the delayed ticker in these scenarios
- The session state continues to be Session.State.Opened
Attaching logs from the data library for scenarios 1 & 2
Answers
-
Hello Rakan,
Could you please send those 2 log files to cristian.baciuwahl@lseg.com ? Due to specific security constraints I am not allowed to open attachments from posts using my work machine.
Also, could you please provide some code samples in the comments so that we can investigate and attempt to recreate the possible issue?
Regarding your 3 scenarios:
- I'm presuming this is the expected happy path - stream connects, refresh is followed by updates with no issues.
- If you receive an "access denied" response, you might have to contact the Content teams to verify your machine account for any license issues preventing you from accessing that data. The library does not send any "access denied" messages/logs by itself, meaning these messages are coming from the backend. What happens with these instruments when you subscribe to them again?
- The backend has decided to close the connection, but if the machine is still logged in into the session, the library will retry a couple of times to reconnect, while keeping the session open. The session is usually closed only when authentication fails or when the user explicitly closes it, so point 3 might be related to point 2, but not necessarily.
Best regards,
Baciu Wahl Cristian
0 -
Apologies for the wait, I was doing more testing. I switched to the LSEG Data .Net Library and have seen that the inconsistent behaviour has disappeared, however there is still an issue I am encountering.
With .NET Framework 4.8, the following disconnect happens consistently:
WARN|LSEG.Data.Delivery.Stream.OMMConnection|Microsoft's ClientWebSocket connection terminated. Code: InvalidState. Reason: [The 'System.Net.WebSockets.InternalClientWebSocket' instance cannot be used for communication because it has been transitioned into the 'Aborted' state.]
WARN|LSEG.Data.Core.DesktopSessionCore|Failed to establish a Desktop stream. "Connection to the WebSocket server [localhost:9001/api/rdp/streaming/pricing/v1/WebSocket] down. Microsoft's ClientWebSocket connection terminated. Code: InvalidState. Reason: [The 'System.Net.WebSockets.InternalClientWebSocket' instance cannot be used for communication because it has been transitioned into the 'Aborted' state.]. Retrying in 15 seconds."
This happens as we are subscribing to streams for various tickers. Note: We use OpenAsync. When the disconnect occurs, the tickers that had requested a stream will eventually reconnect and stream prices, but the tickers that had not requested prior to disconnect will NOT re-request/continue requesting.
This was reproduced with both Desktop & Platform connections using the following code (I used the sample project found on Example.DataLibrary.DotNet/src/2. Content/2.2-Pricing/2.2.05-Pricing-StreamingEvents at lseg-data-examples · LSEG-API-Samples/Example.DataLibrary.DotNet):
static void Main(string[] _)
{
try
{
session = Sessions.GetSession();
// Open the session
session.Open();
foreach (string ticker in tickers)
{
// Create a streaming price interface for a list of instruments and specify lambda expressions to capture real-time updates
var stream = Pricing.Definition(ticker).Fields("DSPLY_NAME", "BID", "ASK")
.GetStream().OnRefresh((item, refresh, s) => DisplayRefresh(item, refresh))
.OnUpdate((item, update, s) => DisplayUpdate(item, update))
.OnStatus((item, status, s) => Console.WriteLine(status))
.OnError((item, err, s) => Console.WriteLine(err));
stream.OpenAsync();
}
// Pause on the main thread while updates come in. Wait for a key press to exit.
Console.WriteLine("Streaming updates. Press any key to stop...");
Console.ReadKey();
}
catch (Exception e)
{
Console.WriteLine($"\n**************\nFailed to execute.");
Console.WriteLine($"Exception: {e.GetType().Name} {e.Message}");
if (e.InnerException != null) Console.WriteLine(e.InnerException);
Console.WriteLine("***************");
}
}I switched the project to a .NET Framework 4.8 version in order to reproduce the issue (was not reproducing in .NET 7). Note: AlphaDesk is a .NET Framework application so upgrading is not a viable solution + I see that .net 4.8 is supposedly supported.
Please let me know if we are doing something wrong or if possibly the library has a bug in the .net 4.8 version. I will also send a log of the reproduced issue via email
0 -
Hello Rakan,
Thank you for the update. I will investigate as soon as possible. At first glance, it looks like there is an issue at the web socket level while iterating through the ticker list and opening the streams and you are able to reproduce it on .NET 4.8, but not on .NET 7. Also, thank you for the code example, this will help us in our investigation.
Best regards,
Baciu Wahl Cristian
0 -
Hello @RakanK
To open multiple tickers using the Pricing definition, you can pass a list containing multiple instruments when creating the definition to obtain data from multiple instruments. Later on, even after the stream is opened, you can add/remove instruments from the watchlist of the definition. The example you linked (2.2.05), provides similar functionality. Make sure that you are opening the task using the recommended async-await pattern.
Below, I have provided a complete example that works with both platform and desktop sessions on .NET 4.8.
internal class PricingStreamWithMultipleTickers
{
public static async Task Run()
{
// We are currently using a desktop session
// To use a platform session remove the parameter in GetSession()
using (ISession session = Sessions.GetSession("desktop"))
{
session.Open();
var tickers = new List<string>
{
"ICAG.L", "RIO.L", "REL.L", "PRU.L", "RKT.L", "GBP=", "LLOY.L", "SBRY.L", "TSCO.L",
"VOD.L", "NG.L", "CAD=", "LIN.O", "ABBV.K", "BRKb", "CAT", "ULVR.L", "ABT", "CRM"
};
// You can add multiple instruments when creating the definition
var stream = Pricing.Definition(tickers)
.Fields("DSPLY_NAME", "BID", "ASK")
.GetStream()
.OnRefresh((item, refresh, s) => DisplayRefresh(item, refresh))
.OnUpdate((item, update, s) => DisplayUpdate(item, update))
.OnStatus((item, status, s) => Console.WriteLine(status))
.OnError((item, err, s) => Console.WriteLine(err));
// Open the stream to receive data
await stream.OpenAsync();
// You can add new instruments later on to the pricing watchlist
stream.AddItems("USD=");
// Or you can remove existing instruments from the watchlist
stream.RemoveItems("GBP=");
Console.WriteLine("Streaming updates. Press any key to stop...");
Console.ReadKey();
}
}
private static void DisplayRefresh(string item, JObject refresh)
{
Console.WriteLine($"Refresh for item {item} {refresh["Fields"]}");
}
private static void DisplayUpdate(string item, JObject update)
{
var fields = update["Fields"];
Console.WriteLine($"{DateTime.Now:HH:mm:ss} Seqno: {update["SeqNumber"],-6} => {item}" +
$"({fields["BID"],6}/{fields["ASK"],6}) - {fields["DSPLY_NAME"]}");
}
}Please let us know how this works for you!
Best regards,
Baciu Wahl Cristian
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 684 Datastream
- 1.4K DSS
- 615 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 249 ETA
- 554 WebSocket API
- 37 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 275 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 643 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- 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
- 45 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
- 26 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 192 TREP Infrastructure
- 228 TRKD
- 915 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 90 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛