Results 1 to 7 of 7
  1. #1

    Using Lightstreamer with Apache

    Hi guys,
    I cant connect my index.html with Lighstreamer Adapter
    My current configs below:

    Lightstreamer Server (192.168.247.13:8080) -->> Apache Server (192.168.247.14)

    My index.html: (lightstreamer.js generated from generator.html, this index.html is on Apache Server)
    Code:
    <!DOCTYPE html>
    <html>
      <head>
        <title>Hello World with Lightstreamer</title>
        <script src="lightstreamer.js"></script>
      </head>
     
      <body>
        <div data-source="lightstreamer" data-grid="hellogrid" data-item="greetings" data-field="message">loading...</div>
        <div data-source="lightstreamer" data-grid="hellogrid" data-item="greetings" data-field="timestamp">loading...</div>
     
        <script>
            var myClient = new LightstreamerClient("http://192.168.247.13");
            myClient.connect();
            var grid = new StaticGrid("hellogrid",true);
     
            var subscription = new Subscription("MERGE",grid.extractItemList(),grid.extractFieldList());
            subscription.setDataAdapter("MYSOCKET");
            subscription.addListener(grid);
     
            myclient.subscribe(subscription);
        </script>
      </body>
    </html>
    adapters.xml:
    Code:
    <?xml version="1.0"?>
    <adapters_conf id="MYSOCKET">
     
      <metadata_provider>
        <adapter_class>com.lightstreamer.adapters.metadata.LiteralBasedProvider</adapter_class>
      </metadata_provider>
     
      <data_provider>
        <adapter_class>com.lightstreamer.adapters.remote.data.NetworkedDataProvider</adapter_class>
          <param name="request_reply_port">7001</param>
          <param name="notify_port">7002</param>
          <param name="timeout">36000000</param>
      </data_provider>
     
    </adapters_conf>
    push.php: (Im using this to push data)
    Code:
    <?php
     
    $server = '127.0.0.1';
    $syncPort = 7001;
    $asyncPort = 7002;
     
     
    $control = fsockopen($server, $syncPort, $errno, $errstr, 5) or die($errno." : ".$errstr."\n");
    $feed = fsockopen($server, $asyncPort, $errno, $errstr, 5) or die($errno." : ".$errstr."\n");
     
     
    $greeting = fscanf($control, "%s\n");
    $sid = explode('|', $greeting[0]);
    $sid = $sid[0];
     
     
    fwrite($control, $sid."|SUB|V\n");
    $cnt = 0;
    while (true) {
            $qry = "0|UD3|S|greetings|S|".$sid."|B|0|S|message|S| Do you count the following?|S|timestamp|S|Count: ".$cnt."\n";
            fwrite($feed, $qry);
            $cnt++;
            sleep(2);
    }
    fclose($feed);
    fclose($control);
    ?>
    The browser shows "loading...". Can anyone help me this problem Im completely stucked
    Last edited by vielktus; October 3rd, 2013 at 07:17 AM.

  2. #2
    Administrator
    Join Date
    Feb 2012
    Location
    Milano
    Posts
    503
    Hi vielktus,

    Do you confirm me that with the JavaScript Client library generator you have chose the "globals" style? Please consider that if you have chose the "AMD" style (default) you should change the js client code in order to use the require.js lib. Please refer to the "Example usage based on the chosen style" of the generator page.

    Anyway please consider that your js client code needs a couple of fix:
    - add port number to the Lightstreamer server url;
    - consider that by your adapters configuration the Adapter Set name is "MYSOCKET", and the Adapter name is not specified ("DEFAULT" assumed);

    ie:

    Code:
      var myClient = new LightstreamerClient("http://192.168.247.13:8080", "MYSOCKET"); 
      myClient.connect();
      
      var grid = new StaticGrid("hellogrid",true);
     
      var subscription = new Subscription("MERGE",grid.extractItemList(),grid.extractFieldList());
      // subscription.setDataAdapter("MYSOCKET");
      subscription.addListener(grid);
     
      myclient.subscribe(subscription);

  3. #3
    Quote Originally Posted by giuseppe.corti View Post
    Hi vielktus,

    Do you confirm me that with the JavaScript Client library generator you have chose the "globals" style? Please consider that if you have chose the "AMD" style (default) you should change the js client code in order to use the require.js lib. Please refer to the "Example usage based on the chosen style" of the generator page.

    Anyway please consider that your js client code needs a couple of fix:
    - add port number to the Lightstreamer server url;
    - consider that by your adapters configuration the Adapter Set name is "MYSOCKET", and the Adapter name is not specified ("DEFAULT" assumed);

    ie:

    Code:
      var myClient = new LightstreamerClient("http://192.168.247.13:8080", "MYSOCKET"); 
      myClient.connect();
      
      var grid = new StaticGrid("hellogrid",true);
     
      var subscription = new Subscription("MERGE",grid.extractItemList(),grid.extractFieldList());
      // subscription.setDataAdapter("MYSOCKET");
      subscription.addListener(grid);
     
      myclient.subscribe(subscription);
    Okay, thats my bad :d. Im using AMD. But now i choose Global as you said. But its still no hope. I figure out this:

    This script Works:
    Code:
    <!DOCTYPE html><html>
      <head>
        <title>Hello World with Lightstreamer</title>
        <script src="http://cdnjs.cloudflare.com/ajax/libs/require.js/1.0.7/require.min.js"></script>
        <script src="lightstreamer.js"></script>
      </head>
    
    
      <body>
        <div data-source="lightstreamer" data-grid="hellogrid" data-item="greetings" data-field="message">loading...</div>
        <div data-source="lightstreamer" data-grid="hellogrid" data-item="greetings" data-field="timestamp">loading...</div>
    
    
        <script>
          require(["LightstreamerClient","Subscription","StaticGrid"],function(LightstreamerClient,Subscription,StaticGrid) {
            var client = new LightstreamerClient("http://192.168.247.13:8080","MYSOCKET");
            client.connect();
    
    
            var grid = new StaticGrid("hellogrid",true);
    
    
            var subscription = new Subscription("MERGE",grid.extractItemList(),grid.extractFieldList());
            subscription.addListener(grid);
    
    
            client.subscribe(subscription);
          });
        </script>
      </body>
    </html>
    This script not works:
    Code:
    <!DOCTYPE html><html>
      <head>
        <title>Hello World with Lightstreamer</title>
        <script src="lightstreamer.js"></script>
      </head>
    
    
      <body>
        <div data-source="lightstreamer" data-grid="hellogrid" data-item="greetings" data-field="message">loading...</div>
        <div data-source="lightstreamer" data-grid="hellogrid" data-item="greetings" data-field="timestamp">loading...</div>
    
    
        <script>
            var myClient = new LightstreamerClient("http://192.168.247.13:8080","mysocket");
            myClient.connect();
            var grid = new StaticGrid("hellogrid",true);
    
    
            var subscription = new Subscription("MERGE",grid.extractItemList(),grid.extractFieldList());
            subscription.addListener(grid);
    
    
            myClient.subscribe(subscription);
        </script>
      </body>
    </html>
    I'm not sure about the lighstreamer.js and the require.min.js in the one works. Maybe i copied from the Demo, not the generator.

    But when i get one works to my Web on Apache, the one works still not works, i think i get stucked at the wrong Java script Included in Head tag:
    Code:
    <head>
    <title>Hello World with Lightstreamer</title>
        <script src="http://cdnjs.cloudflare.com/ajax/libs/require.js/1.0.7/require.min.js"></script>
        <script src="lightstreamer.js"></script>
      </head>
    Can you help me to choose the right Java Script and the right <script>...</script> block to connect ?
    Last edited by vielktus; October 4th, 2013 at 09:37 AM.

  4. #4
    Administrator
    Join Date
    Feb 2012
    Location
    Milano
    Posts
    503
    Please note that the Adapter Set name and Adapter name are case sensitive. So I suppose that the "globals style" example doesn't work due to the "mysocket" instead of "MYSOCKET".

    Anyway, we usually recommend using the AMD version of JavaScript Client library. The fact that your example does not work in Apache is somewhat strange. What kind of error you have? The page loads but the cells shows "loading ..."? Did you notice any errors or messages in the JavaScript console of your browser?

  5. #5
    Okay, good news, i found it but still dont know how to fix It might include in the javascript

    I copied lightstreamer.js in the one works to my Web App Folder (Im using Code Igniter for my App). This is my config:
    • The path: [web root]/asset/lightstreamer.js
    • I include lightstreamer.js in the header.php:

    Code:
    <script src="<?php echo base_url().'asset/';?>js/lightstreamer.js"></script>
    <script src="http://cdnjs.cloudflare.com/ajax/libs/require.js/1.0.7/require.min.js"></script>
    
    My base_url (for your details): <script src="http://192.168.247.14/stream/asset/js/lightstreamer.js"></script>


    Below is the problem i found in the Chrome Debug console:
    Code:
    
    
    
    
    
    
    
    
    
    
    
    


    i dont know where are these: Subscription.js, StaticGrid.js, LightstreamerClient.js

    I guess i must config the path in the require.min.js to fit with my CodeIgniter Please help me. This is the root cause, im sure.

  6. #6
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    Hi,

    I'm not familiar with code igniter, anyway from the errors you see I can tell you that when you do your require call require.js is trying to fetch the classes from your webserver because it thinks that such classes are not yet on the page: this happens because you include lightstreamer.js before including require.js: switch the two scripts and the 404 errors should disappear

  7. #7
    Quote Originally Posted by Mone View Post
    Hi,

    I'm not familiar with code igniter, anyway from the errors you see I can tell you that when you do your require call require.js is trying to fetch the classes from your webserver because it thinks that such classes are not yet on the page: this happens because you include lightstreamer.js before including require.js: switch the two scripts and the 404 errors should disappear
    You've just saved my day, you know Thanks so much

 

 

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 12:06 PM.