eclipse / tahu

Eclipse Tahu addresses the existence of legacy SCADA/DCS/ICS protocols and infrastructures and provides a much-needed definition of how best to apply MQTT into these existing industrial operational environments.
https://eclipse.org/tahu
Eclipse Public License 2.0
223 stars 128 forks source link

node-red-contrib-sparkplug requires MQTT user and password to work #11

Open jhottell opened 5 years ago

jhottell commented 5 years ago

flows.nodered.org and npmjs.com both reference the old Cirrus-Link Sparkplug repository. I have numerous issues with Sparkplug inside of Node-RED and am not sure where to report my bugs...

EDIT: I removed my list of bugs and put them in their own issues to be more proper.

Node-red-contrib-sparkplug cannot work without a MQTT user and password. If you drag the SparkPlug node onto a flow and click Deploy you will get two errors:

  1. "Error creating new client"
  2. "TypeError: Cannot read property 'on' of undefined" Then edit the SparkPlug node and type in a user name and password then click Deploy and you the errors will be gone. You can make it do it again by deleting out user and password.
jtmoderate876 commented 5 years ago

Same here with

If you drags the SparkPlug node onto a flow and click Deploy you will get two errors:

"Error creating new client" "TypeError: Cannot read property 'on' of undefined" Then edit the SparkPlug node and type in a user name and password then click Deploy and you the errors will be gone. You can make it do it again by deleting out user and password.

theonlypwner commented 3 years ago

This occurs because of

https://github.com/eclipse/tahu/blob/05b70284c3f564cb5449a67ac6702ae5d6e104ee/client_libraries/javascript/node-red-contrib-sparkplug/sparkplug/sparkplug.js#L86-L94

https://github.com/eclipse/tahu/blob/05b70284c3f564cb5449a67ac6702ae5d6e104ee/client_libraries/javascript/sparkplug-client/index.js#L25-L47

The first error occurs because an exception is thrown and caught when username is missing. The call to node.error is incorrect; it should contain one exception object as the first argument, and the original msg as the second argument (which should be omitted or undefined in this case).

This means we get one error "Error creating new client" with the original exception swallowed. The catch block doesn't prevent the following code from running, so sparkplugClient.on('birth', ...); results in "TypeError: Cannot read property 'on' of undefined" because sparkplugClient is null after the constructor threw.

beckerben commented 3 years ago

I can confirm this bug still exists, bypassed it by setting up broker with authentication

ghost commented 3 years ago

I can confirm this bug still exists.