Jump to content
Sign in to follow this  
marc

Update Error with Lightstreamer Net Client on DefaultPrices

Recommended Posts

Hi guys, I want to report a problem I’ve seen with the Lightstreamer Net client when I was trying to get the “DefaultPrices” using an ExtendedTableInfo object. Let me say that there is a simple work around it (using a SimpleTableInfo) but I think it still worth listing the problem on here as it can be useful to other people (and as you can see in this post, I’m not the only one who has run into it).

Note that the CIAPI.cs implements the SimpleTableInfo, so everyone using CIAPI.cs will be fine.

The problem I’ve got is that I can only get the first set of data (for the EUR/USD market), and the lightstreamer .Net Client throws a PushServerException (with Wrong Item Number as message) for the 7 other sets of market data returned.

Error in received values Lightstreamer.DotNet.Client.PushServerException: Wrong item number
   at Lightstreamer.DotNet.Client.FullTableManager.ProcessUpdate(ServerUpdateEvent values, Int32 itemPos, Int32 itemIndex) in c:\LIGHTSTREAMER\PROJECT_Lightstreamer_3_DotNetClient_1\DotNetClient\Source\FullTableManager.cs:line 234
   at Lightstreamer.DotNet.Client.FullTableManager.DoUpdate(ServerUpdateEvent values) in c:\LIGHTSTREAMER\PROJECT_Lightstreamer_3_DotNetClient_1\DotNetClient\Source\FullTableManager.cs:line 214
   at Lightstreamer.DotNet.Client.MyServerListener.OnUpdate(ITableManager table, ServerUpdateEvent values) in c:\LIGHTSTREAMER\PROJECT_Lightstreamer_3_DotNetClient_1\DotNetClient\Source\MyServerListener.cs:line 75

Using Fiddler, I can see that 8 sets of data have been sent from the server to the client, but for some reason the client cannot retrieve anythng else than the first set (MarketId = 400494226)

PROBE  

1,2|400494234|\u005C/Date(1325884513179)\u005C/|1.54303|1.54353|1.54328|1.55252|1.53760|-0.00626|1|sbPreProdFX91678343
1,4|400494241|\u005C/Date(1325884513197)\u005C/|0.95488|0.95533|0.95511|0.95789|0.95061|0.00268|1|sbPreProdFX78238222  
1,8|400494179|\u005C/Date(1325884513104)\u005C/|1.02256|1.02316|1.02286|1.02718|1.02018|-0.00337|1|sbPreProdFX75296235
1,7|400494220|\u005C/Date(1325884513129)\u005C/|97.917|97.951|97.934|98.857|97.911|-0.695|1|sbPreProdFX93918355  
1,5|400494249|\u005C/Date(1325884513229)\u005C/|3.53472|3.54382|3.53927|3.54000|3.49985|0.01657|0|sbPreProdFX90055666  
1,3|400494246|\u005C/Date(1325884513223)\u005C/|76.986|77.012|76.999|77.339|76.968|-0.126|1|sbPreProdFX91678452  
1,6|400494215|\u005C/Date(1325884513127)\u005C/|1.21461|1.21524|1.21492|1.21978|1.21483|-0.00308|1|sbPreProdFX75296285
1,1|400494226|\u005C/Date(1325884513155)\u005C/|1.27175|1.27203|1.27189|1.28127|1.26977|-0.00694|1|sbPreProdFX93918338  

LOOP

I’m not expecting any resolution of this issue (not sure if it’s not a bug with the Lighstreamer Net client), but if someone is interrested to reproduce, here is a very small code sample that I’ve put together (just copy the snippet into the program.cs of a VS Console app and make sure you add a reference to the lightstreamer DotNetClient_N2.dll assembly).

To make this code works, comment out the use of ExtendedTableInfo and uncomment the following lines to use SimpleTableInfo.

using System;
using Lightstreamer.DotNet.Client;

class Program
{
    static void Main()
    {
        var lsClient = new LSClient();
        var connectionInfo = new ConnectionInfo
                                 {
                                     PushServerUrl = "https://pushpreprod.cityindextest9.co.uk",
                                     Adapter = "CITYINDEXSTREAMINGDEFAULTPRICES"
                                 };
        lsClient.OpenConnection(connectionInfo, new MyConnectionListener());

        var tableInfo = new ExtendedTableInfo(new[] { "AC2347" },
                                              "MERGE",
                                              new[] {"MarketId", "TickDate", "Bid", "Offer", "Price", "High",
                                                          "Low", "Change", "Direction", "AuditId"},
                                              true);
        //var tableInfo = new SimpleTableInfo("AC2347",
        //                                    "MERGE",
        //                                    "MarketId TickDate Bid Offer Price High Low Change Direction AuditId",
        //                                    true);
        tableInfo.DataAdapter = "PRICES";

        SubscribedTableKey tableKey = null;
        try
        {
            tableKey = lsClient.SubscribeTable(tableInfo, new MyTableListener(), false);

            Console.WriteLine("Press a key to quit...");
            Console.ReadKey();
        }
        catch (Exception ex)
        {
            Console.WriteLine("Exception: {0}", ex);
        }
        finally
        {
            lsClient.UnsubscribeTable(tableKey);
            lsClient.CloseConnection();
        }
    }

    class MyConnectionListener : IConnectionListener
    {
        public void OnDataError(PushServerException ex)
        {
            Console.WriteLine("Exception: {0}", ex);
        }
        public void OnFailure(PushServerException ex) { }
        public void OnFailure(PushConnException ex) { }
        public void OnConnectionEstablished() { }
        public void OnSessionStarted(bool isPolling) { }
        public void OnNewBytes(long bytes) { }
        public void OnActivityWarning(bool warningOn) { }
        public void OnClose() { }
        public void OnEnd(int cause) { }
    }

    class MyTableListener : IHandyTableListener
    {
        public void OnUpdate(int itemPos, string itemName, IUpdateInfo update)
        {
            Console.WriteLine("\nMyTableListener.OnUpdate - ItemPos:{0} - itemName:{1}", itemPos, itemName);
            for (int index = 1; index < update.NumFields + 1; index++)
            {
                Console.WriteLine("oldValue:{0} -> newValue:{1}", update.GetOldValue(index), update.GetNewValue(index));
            }
        }
        public void OnSnapshotEnd(int itemPos, string itemName) { }
        public void OnRawUpdatesLost(int itemPos, string itemName, int lostUpdates) { }
        public void OnUnsubscr(int itemPos, string itemName) { }
        public void OnUnsubscrAll() { }
    }
}

Share this post


Link to post
Guest mrdavidlaing

Thanks for the pointers. We recommend that you don’t use the ExtendedTableInfo.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×