I'm getting error my this code
Quote:
Originally Posted by
malir
YaHoo
In the internet I can't find an example of PHP application in lightstreamer hence I write it. Just save as in the file and type "php filename.php".
PHP Code:
<?
$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);
?>
I used this code and i'm getting following error, Please help me what is my mistake and how to use this
Notice: fwrite(): send of 88 bytes failed with errno=10053 An established connection was aborted by the software in your host machine. in C:\wamp\www\lightsample\index.php on line 17
Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\www\lightsample\index.php on line 20
Creating Data Adapter using PHP
I used this code within the lightstreamer/adapters/HelloWorld/classes
(I'm running lighrstreamer in 8880 port)
//HelloWorldDataAdapter.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);
?>
and added the client file as
<!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>
<div data-source="lightstreamer" data-grid="hellogrid" data-item="greetings" data-field="samplename">loading...</div>
<script>
require(["LightstreamerClient","Subscription","StaticGr id"],function(LightstreamerClient,Subscription,StaticG rid) {
var client = new LightstreamerClient("http://localhost:8880/","HELLOWORLD");
client.connect();
var grid = new StaticGrid("hellogrid",true);
var subscription = new Subscription("MERGE",grid.extractItemList(),grid.e xtractFieldList());
subscription.addListener(grid);
subscription.setDataAdapter("helloworld");
client.subscribe(subscription);
});
</script>
</body>
</html>
and added the adapter xml file as(lightstreamer/adapters/HelloWorld/adapters.xml)
<?xml version="1.0"?>
<adapters_conf id="HELLOWORLD">
<metadata_provider>
<adapter_class>com.lightstreamer.adapters.metadata .LiteralBasedProvider</adapter_class>
</metadata_provider>
<data_provider name="helloworld">
<adapter_class>HelloWorldDataAdapter</adapter_class>
</data_provider>
</adapters_conf>
I created the client and server file as mentioned above structure. I'm also having doubt in creating file structure. Whether it is correct or having problem. If it is wrong means please give me an example of file constructing structure.If i used java as an adapter means it's running well.
Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\www\lightsample
Really I heartily thanking you,
Just now i could get understand about Lightstreamer and its adapter and client files. Too much of thanks to you. Based on this i have to develop stock market rates to client. We are developing application for bullion client. In that we are getting market rates from one third party application and we will add some of the margin and will display to users. Now i used ajax with settimeout() function to read file and display to client browser for every 200 mil second. Please give me some ideas to do this using lightstreamer. I got some basic points if you give some ideas means i can improve my application using lightstreamer.
And also i'm getting error in my php coding like
Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\www\lightsample
Because getting error by indeterminate looping
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);
}
For this i have update php.ini file and changed max_execution_time = 36000000
now my browser continuously running. Is there any problem by this
How can i overcome this. Thanks advance
Creating Adapter in .net(C#)
I have referred LightStreamer Demo and i have written the adapter in c#.
In StandaloneLauncher.cs(in main function) file i have modified as
string host = "localhost";
int rrPortMD = 6650;
int rrPortD = 6651;
int notifPortD = 6652;
string name = null;
and i have modified the code in ExternalfeedSimulater.cs file with my real time data.
And also i have created the adapters.xml file as
<adapters_conf id="GARGTEST">
<metadata_provider>
<adapter_class>com.lightstreamer.adapters.remote.m etadata.NetworkedMetadataProvider</adapter_class>
<param name="request_reply_port">6652</param>
<param name="connection_recovery_timeout_millis">10000</param>
<param name="first_connection_timeout_millis">10000</param>
<param name="close_notifications_recovery">unneeded</param>
</metadata_provider>
<data_provider name="GARGADAPTER">
<adapter_class>com.lightstreamer.adapters.remote.d ata.NetworkedDataProvider</adapter_class>
<param name="request_reply_port">6650</param>
<param name="notify_port">6651</param>
<param name="connection_recovery_timeout_millis">10000</param>
<param name="events_recovery">use_snapshot</param>
</data_provider>
</adapters_conf>
My client file looking like,
<script>
var hostToUse = document.location.protocol == "file:" ? "http://localhost:8080/" : document.location.protocol+"//"+document.location.hostname+(document.location.po rt?":"+document.location.port:"");
define("lsClient",["LightstreamerClient","StatusWidget"],function(LightstreamerClient,StatusWidget) {
var lsClient = new LightstreamerClient("http://localhost:8880/","GARGTEST");
lsClient.connectionSharing.enableSharing("RemoteSt ockListConnection", "ATTACH", "CREATE");
lsClient.addListener(new StatusWidget("left", "0px", true));
lsClient.connect();
return lsClient;
});
</script>
<script type="text/javascript">
require(["lsClient","Subscription","StaticGrid"],
function(lsClient,Subscription,StaticGrid) {
var stocksGrid = new StaticGrid("stocks",true);
stocksGrid.setAutoCleanBehavior(true,false);
stocksGrid.addListener({
onVisualUpdate: function(key,info) {
if (info == null) {
return;
}
var cold = (key.substring(4) % 2 == 1) ? "#eeeeee" : "#ddddee";
info.setAttribute("yellow", cold, "backgroundColor");
}
});
var stockSubscription = new Subscription("MERGE",stocksGrid.extractItemList(), stocksGrid.extractFieldList());
stockSubscription.addListener(stocksGrid);
stockSubscription.setDataAdapter("GARGADAPTER");
stockSubscription.setRequestedSnapshot("yes");
lsClient.subscribe(stockSubscription);
});
</script>
In Lightstreamer/adapters/gargtest/lib i had put the file ls-proxy-adapters.jar
But when i run this code getting error
http://localhost:8880/lightstreamer/create_session.js creation failed(continuously trying to connect session but getting error)