tahu icon indicating copy to clipboard operation
tahu copied to clipboard

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

Open jhottell opened this issue 6 years ago • 4 comments

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.

jhottell avatar Jan 16 '19 18:01 jhottell

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.

jtmoderate876 avatar Jan 17 '19 14:01 jtmoderate876

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.

theonlypwner avatar Feb 27 '21 00:02 theonlypwner

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

beckerben avatar Apr 22 '21 16:04 beckerben

I can confirm this bug still exists.

ghost avatar Aug 19 '21 13:08 ghost