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)
<!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:
<?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)
<?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 :Smile_Ac: Im completely stucked
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:
[COLOR="#FF0000"]var myClient = new LightstreamerClient("http://192.168.247.13:8080", "MYSOCKET");[/COLOR] 
  myClient.connect();
  
  var grid = new StaticGrid("hellogrid",true);
 
  var subscription = new Subscription("MERGE",grid.extractItemList(),grid.extractFieldList());
 [COLOR="#FF0000"]// subscription.setDataAdapter("MYSOCKET");[/COLOR] 
  subscription.addListener(grid);
 
  myclient.subscribe(subscription);

    Giuseppe Corti 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:

    [COLOR=#FF0000]var myClient = new LightstreamerClient("http://192.168.247.13:8080", "MYSOCKET");[/COLOR] 
      myClient.connect();
      
      var grid = new StaticGrid("hellogrid",true);
     
      var subscription = new Subscription("MERGE",grid.extractItemList(),grid.extractFieldList());
     [COLOR=#FF0000]// subscription.setDataAdapter("MYSOCKET");[/COLOR] 
      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:
    <!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:
    <!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.jsand 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:
    <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 ?
    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?
    Okay, good news, i found it but still dont know how to fix :confused: It might include in the javascript

    I copied lightstreamer.jsin 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:
    <script src="<?php echo base_url().'asset/';?>js/lightstreamer.js"></script>[COLOR=#000000]
    [/COLOR]<script src="http://cdnjs.cloudflare.com/ajax/libs/require.js/1.0.7/require.min.js"></script>
    [COLOR=#000000]
    My base_url (for your details): [/COLOR]<script src="[COLOR=#ff0000][B]http://192.168.247.14/stream/asset/js/lightstreamer.js[/B][/COLOR]"></script>


    Below is the problem i found in the Chrome Debug console:
    [LIST]
    [*]GET  [URL]http://192.168.247.14/stream/Subscription.js[/URL]404 (Not Found) [URL="http://cdnjs.cloudflare.com/ajax/libs/require.js/1.0.7/require.min.js"]require.min.js:29[/URL] 
    [/LIST]
    
    
    [LIST]
    [*]GET  [URL]http://192.168.247.14/stream/StaticGrid.js[/URL]404 (Not Found) [URL="http://cdnjs.cloudflare.com/ajax/libs/require.js/1.0.7/require.min.js"]require.min.js:29[/URL] 
    [/LIST]
    
    
    [LIST]
    [*]GET  [URL]http://192.168.247.14/stream/LightstreamerClient.js[/URL]404 (Not Found) [URL="http://cdnjs.cloudflare.com/ajax/libs/require.js/1.0.7/require.min.js"]require.min.js:29[/URL] 
    [/LIST]
    
    
    [LIST]
    [*][COLOR=red !important]Uncaught Error: Load timeout for modules: LightstreamerClient Subscription StaticGrid  [URL]http://requirejs.org/docs/errors.html#timeout[/URL][URL="http://cdnjs.cloudflare.com/ajax/libs/require.js/1.0.7/require.min.js"]require.min.js:7[/URL] [/COLOR]
    [/LIST]
    
    


    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 :Smile_Ac: Please help me. This is the root cause, im sure.
    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

      Mone 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 :Smile_Ag: Thanks so much :Smile_Ag: