Posts: 71
Threads: 12
Joined: Jul 2015
Reputation:
0
Hi all,
On my intranet I was listening to the KNX Bus via long polling and ajax requests using
/cgi-bin/scada-vis/general/objects-update.cgi
Since updating to firmware 20160927, this no longer works, I haven't had time to dig into it yet. Is there a new state-of-the-art way to listen to the bus which will update values on a webpage without reloading the page (i.e. to update a field containing a temperature value, or switch status, etc.)
Best regards,
Robin
Posts: 1764
Threads: 6
Joined: Jul 2015
Reputation:
117
Hi Robin,
Long polling is changed to websocket connection.
Never done external from other server but should be possible i guess.
Lets wait what admin say (:
Posts: 71
Threads: 12
Joined: Jul 2015
Reputation:
0
Hi Erwin
Thank you! Therefore we'll wait for the admin.
Posts: 7775
Threads: 42
Joined: Jun 2015
Reputation:
447
Long polling is still there, but only for the admin part, so as a temporary solution you can access it via /scada-main/objects/update
I'll prepare a WebSocket example later on.
Posts: 71
Threads: 12
Joined: Jul 2015
Reputation:
0
Websocket example would be fantastic!
Posts: 165
Threads: 82
Joined: Jul 2015
Reputation:
1
Hello , I have a question. Should websocket use a different port http port ? Or can we use same TCP port ?
Regards
Posts: 7775
Threads: 42
Joined: Jun 2015
Reputation:
447
Same port is used for both WebSockets and standard HTTP requests.
Posts: 5
Threads: 1
Joined: Dec 2016
Reputation:
0
Hi All,
Can anyone share a Websocket example which is working with same HTTP port ?
Thanks
BR
Ceyhan
Posts: 7775
Threads: 42
Joined: Jun 2015
Reputation:
447
Here's a short example for how it can work via WebSocket, the problem is that this example requires latest beta firmware and work won't on 2016.09.30.
Code: <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="http://192.168.1.9/apps/js/jquery.js.gz"></script>
<script src="http://192.168.1.9/apps/js/localbus.js.gz"></script>
<script src="http://192.168.1.9/scada/vis/busdecode.js.gz"></script>
</head>
<body>
<script>
$(function() {
// listen to all groupwrite telegrams
localbus.listen('groupwrite', function(event) {
console.log(event);
});
// listen to a single object
localbus.listen('object', '1/1/1', function(value) {
console.log(value);
});
localbus.init('http://192.168.1.9');
});
</script>
</body>
</html>
(28.12.2016, 12:29)ceyhanc Wrote: Can anyone share a Websocket example which is working with same HTTP port ? Can you explain which kind of data do you want to send over websocket?
Posts: 5
Threads: 1
Joined: Dec 2016
Reputation:
0
03.01.2017, 13:51
(This post was last modified: 03.01.2017, 14:02 by ceyhanc.)
(03.01.2017, 11:26) pid=\2913' Wrote:Here's a short example for how it can work via WebSocket, the problem is that this example requires latest beta firmware and work won't on 2016.09.30.
Code: <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="http://192.168.1.9/apps/js/jquery.js.gz"></script>
<script src="http://192.168.1.9/apps/js/localbus.js.gz"></script>
<script src="http://192.168.1.9/scada/vis/busdecode.js.gz"></script>
</head>
<body>
<script>
$(function() {
// listen to all groupwrite telegrams
localbus.listen('groupwrite', function(event) {
console.log(event);
});
// listen to a single object
localbus.listen('object', '1/1/1', function(value) {
console.log(value);
});
localbus.init('http://192.168.1.9');
});
</script>
</body>
</html>
(28.12.2016, 12:29)ceyhanc Wrote: Can anyone share a Websocket example which is working with same HTTP port ? Can you explain which kind of data do you want to send over websocket?
I need to ask, when localbus.init runs;
1. Does websocket server runs at same ip/port with visualisation ?
2. when we try to listen 1 object; will server push to chaged data or actual data to client ?
3. can we listen multiple objects with [ localbus.listen('object', ] notation ?
We want to take some binary objects true/false values to our native Android/IOS app.
Our aims;
1. We use several alarm objects and get informations of them fastly (like TCP socket communication)
2. We want to server will push to alarm info to client.
3. We want to do all communications with one port. (All LM Visualisation and this information)
4. We dont want to use JSON/XML (It requires reconnect to server for getting informations every 5 sec.)
Thanks
Ceyhan
Posts: 71
Threads: 12
Joined: Jul 2015
Reputation:
0
(03.01.2017, 11:26)admin Wrote: Here's a short example for how it can work via WebSocket, the problem is that this example requires latest beta firmware and work won't on 2016.09.30.
Thanks.
1. Will everything else keep working if I upgrade to the latest beta firmware?
2. Will the websocket code still run in the next official firmware release? (I do not want to reprogram my intranet with every release)
3.
Quote:Long polling is still there, but only for the admin part, so as a temporary solution you can access it via /scada-main/objects/update
Can't get this work, what is the name of the .cgi file in the folder you mentioned?
Many thanks!
Posts: 7775
Threads: 42
Joined: Jun 2015
Reputation:
447
Quote:1. Does websocket server runs at same ip/port with visualisation ?
Yes
Quote:2. when we try to listen 1 object; will server push to chaged data or actual data to client ?
All bus telegrams are pushed no matter how many objects you listen to
Quote:3. can we listen multiple objects with [ localbus.listen('object', ] notation ?
You can have many listeners for each object or use a single telegram listener and filter event by dst group address param
Quote:1. Will everything else keep working if I upgrade to the latest beta firmware?
Nobody knows as it's not fully tested yet
Quote:2. Will the websocket code still run in the next official firmware release? (I do not want to reprogram my intranet with every release)
Yes
Quote:Can't get this work, what is the name of the .cgi file in the folder you mentioned?
The path is http://LM_IP/scada-main/objects/update
Posts: 71
Threads: 12
Joined: Jul 2015
Reputation:
0
03.01.2017, 16:13
(This post was last modified: 03.01.2017, 16:31 by RSV4.)
(03.01.2017, 15:48)admin Wrote: Quote:The path is http://LM_IP/scada-main/objects/update
Thanks. But whats the name of the .cgi file? Is it still objects-update.cgi ( http://LM_IP/scada-main/objects/update/o...update.cgi)? I always got a 404...
Edit: oh- I might have had a /cgi in my path. Will check tonight.
Does websocket also work the other way round, e.g. what is the code to send a grp.write from html/js/jquery?
Posts: 71
Threads: 12
Joined: Jul 2015
Reputation:
0
Tried to fix the polling function, no success. Can you please take at look at this:
Code: poll = function() {
$.ajax({
//url: 'http://10.0.x.xx/cgi-bin/scada-vis/general/objects-update.cgi',
url: 'http://10.0.x.xx/scada-main/objects/update/objects-update.cgi',
type: 'GET',
data: { upd: upd },
error: check,
success: check,
timeout: 60 * 1000
});
};
Code: function read() {
$.ajax({
// url: host + '/cgi-bin/scada-vis/general/request.cgi?_module=objects&_action=main',
url: host + '/scada-main/objects/update/request.cgi?_module=objects&_action=main',
type: 'POST',
dataType: 'json',
data: { updatetime: time, skiptags: 1 },
error: poll,
success: update,
timeout: 15 * 1000
});
}
I tried altering the path as described a few posts above, did not work, see my code snippets above. I also tried adding /cgi-bin/ at the beginning of the altered path, also no success. I'd really like to fix this that my site is up and running again and switch to websocket as soon as the beta firmware is final. Thank you!
Posts: 7775
Threads: 42
Joined: Jun 2015
Reputation:
447
Posts: 7775
Threads: 42
Joined: Jun 2015
Reputation:
447
As for sending values from client you can use these functions (keep in mind that only group addresses can be used here, not object names):
Code: localbus.write('1/1/1', true); // same as grp.write('1/1/1', true)
localbus.update('1/1/2', 42); // same as grp.update('1/1/2', 42)
Posts: 71
Threads: 12
Joined: Jul 2015
Reputation:
0
(04.01.2017, 07:24)admin Wrote: First url should be:
http://10.0.x.xx/scada-main/objects/update
Second one should be:
http://10.0.x.xx/scada-main/objects/main
This does not work. I get a Cross origin error in the web console for http://10.0.x.x/scada-main/objects/updat....cgi?upd=0. Reason "CORS-Header 'Access-Control-Allow-Origin' missing". Ideas?
(04.01.2017, 09:01)admin Wrote: As for sending values from client you can use these functions (keep in mind that only group addresses can be used here, not object names):
Code: localbus.write('1/1/1', true); // same as grp.write('1/1/1', true)
localbus.update('1/1/2', 42); // same as grp.update('1/1/2', 42)
Great, looking forward to that firmware!
Posts: 7775
Threads: 42
Joined: Jun 2015
Reputation:
447
Unfortunately it won't work with current FW due to browser security checks. I can provide beta FW for you test if you want.
Posts: 71
Threads: 12
Joined: Jul 2015
Reputation:
0
That would be great, can you please send the beta firmware to the email I am registered here in the forum? Furthermore, do the packages for MySQL work on the beta firmware? Many thanks!
Posts: 7775
Threads: 42
Joined: Jun 2015
Reputation:
447
Which device do you need the FW for? MySQL will work, but you will have to re-install the packages, because custom packages are not kept during FW upgrade.
|