macchina-io / macchina.io

macchina.io EDGE is a powerful C++ and JavaScript SDK for edge devices, multi-service IoT gateways and connected embedded systems.
https://macchina.io
GNU General Public License v3.0
515 stars 154 forks source link

Web Events not working via Remote Manager #108

Closed pavledragisic closed 2 years ago

pavledragisic commented 3 years ago

Expected Behavior

When accessing Macchina.io Web UI all bundles that are subscribed to Web Events should be notified when Web Event notify method has been called, and then they can access Web Event data. Bundles subscribed to that event should receive event data unrelated to Web UI connection type (Direct access via IP address in LAN or via macchina.io Remote Manager.

Actual Behavior

When accessing Macchina.io Web UI via IP address in LAN Web Events work, and bundles get notified and can access Web Event data. On the other hand when accessing Web UI using Remote Manager bundles that are subscribed don’t get notified and don’t get Web Event data.

Steps to Reproduce

Reproducing this issue can be done using Macchina.io SensorLog bundle. SensorLog bundle is using Web Events to monitor sensor value changes. To see if bundle is receiving Web Events we can just add one console.log in the function that is handling Web Event.

In file macchina.io/samples/SensorLog/bundle/webapp/js/controllers.js / on the line 71 method onNotify should look like this:

WebEvent.onNotify = function(evt) { for (var id in $scope.sensors) { if ('sensorlog.' + id == evt.subject) { $scope.sensors[id].value = parseFloat(evt.data); console.log("SensorLog Event"); console.log(evt.data); } } $scope.$apply(); };

After editing controllers.js recompile SensorLog bundle and start macchina.io. Device running macchina.io should be registered in Remote Manager.

Web UI pages accessed via LAN and Remote Manager are shown bellow. We can see that there is no console log on the page accessed via Remote Manager.

Web UI accessed via LAN SensorLog Local

Web UI accessed via Remote Manager SensorLog RemoteMngr

macchina.io Version

macchina-2020.1-release

Compiler and Version

gcc --version gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0

Operating System and Version

System information: Linux (4.19.150) on armv7l

obiltschnig commented 3 years ago

This is currently a limitation in Remote Manager, as Remote Manager uses the same mechanism. The actual issue is that the request to open the WebSocket for WebEvent is handled by the Remote Manager server and not forwarded to the device.

aleks-f commented 2 years ago

@pavledragisic this functionality does exist, I've needed it and implemented it a while ago, but it is not yet released anywhere

obiltschnig commented 2 years ago

@aleks-f This has already been fixed in macchina.io REMOTE some time ago.

aleks-f commented 2 years ago

ok, I didn't know