Page 1 of 2 12 LastLast
Results 1 to 10 of 26

Hybrid View

  1. #1
    Power Member
    Join Date
    Sep 2013
    Location
    Coimbatore
    Posts
    121

    I have issue on connecting LS server in multiple page

    (App developed my using Ionic Cordova platform.)
    I have an application like trading platform. In my first page, I need to display all of the live rates(List of stocks and their rates). If they click on trade button I need to display only what every tradable stock. And If click on the stock from this I need to display responding stock details and Bid and Ask price and from this screen, users will submit their required quantity and submit the page. For every page currently, i'm opening the new connection.

    var protocolToUse = document.location.protocol != "file:" ? document.location.protocol : "http:";
    var portToUse = document.location.protocol == "https:" ? "443" : "8080";
    var lsClient = new Lightstreamer.LightstreamerClient(protocolToUse+"//domain.com:"+portToUse,"STOCKLIST_REMOTE");
    lsClient.connect();

    As like that connecting in all of my three pages. But If I navigate the pages means connection getting close automatically. Showing the error like session terminated. Could you please help me anyone to fix this issue. Or else id there any other way to share the connection(connectionSharing) from one page to another page. I have tried like below code but issue happens. It says have to add connection sharing library.
    lsClient.connectionSharing.enableSharing("CommonCo nnection", "ATTACH", "CREATE");
    And also I need if we use connectionsharring means how to use that shared connection in another page.
    I have below code in all of my three page controller(I'm using ionic framework for my android application )
    var protocolToUse = document.location.protocol != "file:" ? document.location.protocol : "http:";
    var portToUse = document.location.protocol == "https:" ? "443" : "8080";
    var lsClient = new Lightstreamer.LightstreamerClient(protocolToUse+"//domain.com:"+portToUse,"STOCKLIST_REMOTE");
    lsClient.connectionOptions.setHttpExtraHeaders({"u sername" : "bullion"});
    lsClient.addListener({
    onStatusChange: function(newStatus) {
    console.log(newStatus);
    }
    });
    lsClient.connect();
    Last edited by rvkvino; November 27th, 2017 at 08:52 AM.

  2. #2
    Administrator
    Join Date
    Feb 2012
    Location
    Milano
    Posts
    716
    Hi rvkvino,

    ConnectionSharing is the object of our client API that allow to specify if and how the connection is shared between different LightstreamerClient instances.
    If you are using a versiont 7.0.x of Lightstreamer Web Client this is the correct syntax to leverage the engine sharing:

    lsClient.enableSharing(new ConnectionSharing("my_sharing_name", "ATTACH", "CREATE"));

    If you've built your library with the provided generator,please make sure you've included the ConnectionSharing class.

    I confirm that the code should be the same in all your pages and the Lightstramer client will manage out of the box the sharing of a single connection to the server across all LightstreamerClient instances.

    Please, take also a look at this demo that shows a quite similar scenario.

    Regards,
    Giuseppe

  3. #3
    Power Member
    Join Date
    Sep 2013
    Location
    Coimbatore
    Posts
    121
    Hi,
    I have used the code as like below in my all the 3 pages.
    var protocolToUse = document.location.protocol != "file:" ? document.location.protocol : "http:";
    var portToUse = document.location.protocol == "https:" ? "443" : "8080";
    var lsClient = new Lightstreamer.LightstreamerClient(protocolToUse+"//domain.com:"+portToUse,"STOCKLIST_REMOTE");
    lsClient.connectionOptions.setHttpExtraHeaders({"u sername" : "bullion"});
    lsClient.enableSharing(new Lightstreamer.ConnectionSharing("CommonConnection" , "ATTACH", "CREATE"));
    lsClient.addListener({
    onStatusChange: function(newStatus) {
    console.log(newStatus);
    }
    });
    lsClient.connect();
    This idn't work for me, If I navigate from first page to second page stock table didn't display. Connection status showing like connected. AS like this demo I dind't create single lsClient.js file and define into my controller.


  4. #4
    Power Member
    Join Date
    Sep 2013
    Location
    Coimbatore
    Posts
    121
    I have changed the functionality as like below,
    First created global file and in it created lsclient variable and created a connection on that. And for slave pages I have connected and subscribe the LS Server.
    Global Declarationlsconnection.js)
    var protocolToUse = document.location.protocol != "file:" ? document.location.protocol : "http:";
    var portToUse = document.location.protocol == "https:" ? "443" : "8080";
    var lsClient = new Lightstreamer.LightstreamerClient(protocolToUse+"//mydomain.com:"+portToUse,"SLNSTOCKLISTDEMO_REMOTE" );
    lsClient.connectionOptions.setHttpExtraHeaders({"u sername" : "bullion"});
    lsClient.enableSharing(new Lightstreamer.ConnectionSharing("CommonConnection" , "ATTACH", "CREATE"));

    And my all the 3 pages used as like below(slave page)
    lsClient.connect();
    var liverateSubscription = new Lightstreamer.Subscription("COMMAND", liverateId, fieldList);
    //my subscription
    var liverateId = "Item";
    var fieldList = ["key", "command", "desc", "bid", "ask", "high" , "low", "order"];
    var bidaskfieldsList = ["desc", "bid", "ask", "low" , "high", "ratedisplay", "updatetime", "msg"];
    var bidaskitemList = ["Gold", "Silver", "INR", "MGold", "MSilver", "Marketstatus"];

    var liverateSubscription = new Lightstreamer.Subscription("COMMAND", liverateId, fieldList);
    var liverateGrid = new Lightstreamer.DynaGrid("liverates",true);
    liverateGrid.setAutoCleanBehavior(true,false);
    liverateGrid.addListener({
    onVisualUpdate: function(key,info) {
    if (info == null) {
    return;
    }
    info.forEachChangedField(function(fieldName,val) {
    var lastPrice = info.getChangedFieldValue(fieldName);
    if (lastPrice !== null) {
    var prevPrice = liverateGrid.getValue(key,fieldName);
    if(prevPrice != null){
    if (!prevPrice || lastPrice > prevPrice) {
    info.setAttribute("#2636f2",null,"backgroundColor" );
    info.setAttribute("#FFFFFF",null,"color");
    } else {
    info.setAttribute("#FF0000",null,"backgroundColor" );
    info.setAttribute("#FFFFFF",null,"color");
    }
    }
    } else {
    info.setAttribute("",null,"backgroundColor");
    info.setAttribute("",null,"color");
    }
    });

    }
    });
    liverateGrid.setSort("order", false);
    liverateSubscription.setDataAdapter("QUOTE_ADAPTER ");
    liverateSubscription.setRequestedSnapshot("yes");
    liverateSubscription.addListener(liverateGrid);
    lsClient.subscribe(liverateSubscription);
    It is working without terminate the session. But showing unchanged text everywhere mostly. Whenever the rates getting change at that time only showing the rates, after that showing only UNCHANGED text. Attached the screenshot for your reference.
    Click image for larger version. 

Name:	trade.jpg 
Views:	807 
Size:	39.7 KB 
ID:	231

  5. #5
    Administrator
    Join Date
    Feb 2012
    Location
    Milano
    Posts
    716
    Hi rvkvino,

    Please could you confirm that every slave pages declare its own instance of lsClient?

    Thank you,
    Giuseppe

  6. #6
    Power Member
    Join Date
    Sep 2013
    Location
    Coimbatore
    Posts
    121
    Could you please give me the code sample that creating an instance from lsClient. I have tried but showing lsClinet not having constructor method.
    Last edited by rvkvino; November 28th, 2017 at 11:51 AM.

  7. #7
    Administrator
    Join Date
    Feb 2012
    Location
    Milano
    Posts
    716
    Hi rvkvino,

    If a single page application work fine, an application that handles 3 distinct and completely independent pages should work fine as well without leveraging the sharing; for sure you give up some optimization but the app still have to work.
    The attached log refers to a scenario with the sharing active and also does not point out any kind of problem.

    I would suggest to try to understand why the session was lost browsing through the pages.
    Please could you collect the log in this specific case? Furthermore could you add application log in this LightstreamerClient event?

    Regards,
    Giuseppe

  8. #8
    Power Member
    Join Date
    Sep 2013
    Location
    Coimbatore
    Posts
    121
    Please check now, I have commanded the connection sharing code and below code given in all the three page,
    var protocolToUse = document.location.protocol != "file:" ? document.location.protocol : "http:";
    var portToUse = document.location.protocol == "https:" ? "443" : "8080";
    var lsClient = new Lightstreamer.LightstreamerClient(protocolToUse+"//mydomain.com:"+portToUse,"STOCKLIST_REMOTE");
    lsClient.connectionOptions.setHttpExtraHeaders({"u sername" : "bullion"});
    //lsClient.enableSharing(new Lightstreamer.ConnectionSharing("CommonConnection" , "ATTACH", "CREATE"));
    //lsClient.connectionOptions.setCookieHandlingRequir ed(true);

    lsClient.addListener({
    onStatusChange: function(newStatus) {
    console.log(newStatus);
    if(newStatus == "CONNECTED:HTTP-STREAMING"){
    }else if(newStatus == 'DISCONNECTED:WILL-RETRY'){
    }
    }
    });
    lsClient.connect();




    Now log shows like,
    lightstreamer.subscriptions | INFO | 15:05:07,524 | 10] Subscribing subscription {[|Subscription|1|0||0|||] }
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:07,525 | 352] Subscription entered the active state {[|Subscription|5|0|1|1||2|] }
    controllers.js:1704 displaycommodity(length): 1
    controllers.js:56 loginstatus enter: true
    lightstreamer.js:556 lightstreamer.session | INFO | 15:05:07,543 | 273] Opening a new session and starting automatic reconnections. {}
    lightstreamer.js:556 lightstreamer.session | INFO | 15:05:07,547 | 66] Opening new session {[|SessionWS|false|false|1|0|8600|1|0|||false|false|] }
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:07,574 | 191] Control requests queue is now empty {}
    lightstreamer.js:556 lightstreamer.grids | INFO | 15:05:08,801 | 411] Cleaning the model {[|liveratelist|0|0|] }
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:24,568 | 10] Subscribing subscription {[|Subscription|1|0||0|||] }
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:24,568 | 352] Subscription entered the active state {[|Subscription|5|0|1|1||2|] }
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:24,572 | 10] Subscribing subscription {[|Subscription|1|0||0|||] }
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:24,573 | 352] Subscription entered the active state {[|Subscription|5|0|2|1||3|] }
    controllers.js:56 loginstatus enter: true
    lightstreamer.js:556 lightstreamer.session | INFO | 15:05:24,582 | 273] Opening a new session and starting automatic reconnections. {}
    lightstreamer.js:556 lightstreamer.session | INFO | 15:05:24,587 | 66] Opening new session {[|SessionWS|false|false|1|0|7800|1|0|||false|false|] }
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:24,610 | 191] Control requests queue is now empty {}
    controllers.js:773 CONNECTING
    lightstreamer.js:556 lightstreamer.session | INFO | 15:05:24,960 | 247] Session started {[object Object] }
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:25,1 | 185] Stop sending reverse heartbeat to the server {[|ControlConnectionHandler|IDLE||50000|] }
    lightstreamer.js:556 lightstreamer.session | INFO | 15:05:25,17 | 67] Binding session {[|SessionWS|false|false|4|3|7803|5|0|Sdf9c492f868f1 580T0522581|[|WebSocketConnection|false|||false|]|false|false|] }
    lightstreamer.js:556 lightstreamer.session | INFO | 15:05:25,19 | 241] Unable to establish session of the current type. Switching session type {WS Streaming prepare HTTP Streaming }
    lightstreamer.js:556 lightstreamer.session | INFO | 15:05:25,26 | 244] Switching current session type {prepare HTTP Streaming }
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:25,34 | 185] Stop sending reverse heartbeat to the server {[|ControlConnectionHandler|IDLE||50000|] }
    lightstreamer.js:556 lightstreamer.session | INFO | 15:05:25,38 | 67] Binding session {[|SessionHTTP|false|false|4|1|7804|0|Sdf9c492f868f1 580T0522581|false|false|] }
    controllers.js:773 CONNECTED:STREAM-SENSING
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:25,84 | 186] New request to be sent to server {[|ControlConnectionHandler|IDLE||50000|] [object Object] }
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:25,94 | 189] Control request sent through HTTP connection {}
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:25,95 | 186] New request to be sent to server {[|ControlConnectionHandler|WAITING RESP|[|ControlRequestBatch|1|1|]|50000|] [object Object] }
    controllers.js:773 CONNECTED:HTTP-STREAMING
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:25,789 | 192] Control request got answer {4 }
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:25,802 | 353] Subscription is now subscribed to {[|Subscription|4|0|1|2|1|2|] }
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:25,867 | 189] Control request sent through HTTP connection {}
    lightstreamer.js:556 lightstreamer.grids | INFO | 15:05:25,873 | 411] Cleaning the model {[|liverates|0|0|] }
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:26,194 | 192] Control request got answer {7 }
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:26,216 | 353] Subscription is now subscribed to {[|Subscription|4|0|2|2|2|3|] }
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:26,235 | 191] Control requests queue is now empty {}
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:27,996 | 10] Subscribing subscription {[|Subscription|1|0||0|||] }
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:27,997 | 352] Subscription entered the active state {[|Subscription|5|0|1|1||2|] }
    controllers.js:1704 displaycommodity(length): 1
    controllers.js:56 loginstatus enter: true
    lightstreamer.js:556 lightstreamer.session | INFO | 15:05:28,6 | 273] Opening a new session and starting automatic reconnections. {}
    lightstreamer.js:556 lightstreamer.session | INFO | 15:05:28,11 | 66] Opening new session {[|SessionWS|false|false|1|0|4200|1|0|||false|false|] }
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:28,30 | 191] Control requests queue is now empty {}
    controllers.js:1538 CONNECTING
    lightstreamer.js:556 lightstreamer.session | INFO | 15:05:28,367 | 247] Session started {[object Object] }
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:28,379 | 185] Stop sending reverse heartbeat to the server {[|ControlConnectionHandler|IDLE||50000|] }
    lightstreamer.js:556 lightstreamer.session | INFO | 15:05:28,393 | 67] Binding session {[|SessionWS|false|false|4|3|4203|5|0|S3bd7056bf580c 628T0525997|[|WebSocketConnection|false|||false|]|false|false|] }
    lightstreamer.js:556 lightstreamer.session | INFO | 15:05:28,394 | 241] Unable to establish session of the current type. Switching session type {WS Streaming prepare HTTP Streaming }
    lightstreamer.js:556 lightstreamer.session | INFO | 15:05:28,396 | 244] Switching current session type {prepare HTTP Streaming }
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:28,401 | 185] Stop sending reverse heartbeat to the server {[|ControlConnectionHandler|IDLE||50000|] }
    lightstreamer.js:556 lightstreamer.session | INFO | 15:05:28,401 | 67] Binding session {[|SessionHTTP|false|false|4|1|4204|0|S3bd7056bf580c 628T0525997|false|false|] }
    controllers.js:1538 CONNECTED:STREAM-SENSING
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:28,426 | 186] New request to be sent to server {[|ControlConnectionHandler|IDLE||50000|] [object Object] }
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:28,446 | 189] Control request sent through HTTP connection {}
    controllers.js:1538 CONNECTED:HTTP-STREAMING
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:29,187 | 192] Control request got answer {4 }
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:29,201 | 353] Subscription is now subscribed to {[|Subscription|4|0|1|2|1|2|] }
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:29,224 | 191] Control requests queue is now empty {}
    lightstreamer.js:556 lightstreamer.grids | INFO | 15:05:29,231 | 411] Cleaning the model {[|liveratelist|0|0|] }
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:33,53 | 10] Subscribing subscription {[|Subscription|1|0||0|||] }
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:33,53 | 352] Subscription entered the active state {[|Subscription|5|0|1|1||2|] }
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:33,54 | 10] Subscribing subscription {[|Subscription|1|0||0|||] }
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:33,55 | 352] Subscription entered the active state {[|Subscription|5|0|2|1||3|] }
    controllers.js:56 loginstatus enter: true
    lightstreamer.js:556 lightstreamer.session | INFO | 15:05:33,61 | 273] Opening a new session and starting automatic reconnections. {}
    lightstreamer.js:556 lightstreamer.session | INFO | 15:05:33,66 | 66] Opening new session {[|SessionWS|false|false|1|0|1600|1|0|||false|false|] }
    lightstreamer.js:556 lightstreamer.subscriptions | INFO | 15:05:33,85 | 191] Control requests queue is now empty {}

  9. #9
    Administrator
    Join Date
    Feb 2012
    Location
    Milano
    Posts
    716
    Hi rvkvino,

    Also this log does not show anything wrong.
    There are two sessions that start regularly and subscriptions are also successful.

    Please, could you describe in detail the actions taken in the test and the wrong behavior observed?

    Thank you,
    Giuseppe

  10. #10
    Power Member
    Join Date
    Sep 2013
    Location
    Coimbatore
    Posts
    121
    Click image for larger version. 

Name:	slntradeissue.jpg 
Views:	793 
Size:	62.5 KB 
ID:	232
    Please check this screen, I have explained in this images. I'm remain we are using ionic cordova framework to develop the app.

 

 

Similar Threads

  1. How to create 2 engines in one page?
    By dimitarn in forum Client SDKs
    Replies: 5
    Last Post: December 10th, 2009, 11:52 AM
  2. More tables in one page scenario
    By cbrogliato in forum Client SDKs
    Replies: 1
    Last Post: October 2nd, 2009, 03:13 PM
  3. Replies: 5
    Last Post: July 17th, 2008, 11:01 AM
  4. Problem connecting GI to LS server
    By camerone in forum Client SDKs
    Replies: 1
    Last Post: August 20th, 2007, 03:37 PM
  5. Replies: 1
    Last Post: March 15th, 2007, 03:44 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT +1. The time now is 10:40 AM.