Uncaught Exception crashing Node-RED, uncertain how to proceed

Hello,

I'm experiencing a problem with Node-RED. It consistently reports that there is no connection, and I'm uncertain about how to proceed with troubleshooting this issue.

25 Jan 10:26:12 - [info]

Welcome to Node-RED
===================

25 Jan 10:26:12 - [info] Node-RED version: v3.1.3
25 Jan 10:26:12 - [info] Node.js  version: v20.9.0
25 Jan 10:26:12 - [info] Windows_NT 10.0.22621 x64 LE
25 Jan 10:26:13 - [info] Loading palette nodes
25 Jan 10:26:13 - [info] Dashboard version 3.6.1 started at /ui
25 Jan 10:26:13 - [info] Settings file  : C:\Users\nizar_n31aszd\.node-red\settings.js
25 Jan 10:26:13 - [info] Context store  : 'default' [module=memory]
25 Jan 10:26:13 - [info] User directory : \Users\nizar_n31aszd\.node-red
25 Jan 10:26:13 - [warn] Projects disabled : editorTheme.projects.enabled=false
25 Jan 10:26:13 - [info] Flows file     : \Users\nizar_n31aszd\.node-red\flows.json
25 Jan 10:26:13 - [info] Server now running at http://127.0.0.1:1880/
25 Jan 10:26:14 - [warn]

---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.

You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------

25 Jan 10:26:14 - [info] Starting flows
25 Jan 10:26:14 - [error] [ui_led:39f0631ff454fec7] ui_led.error.no-group
25 Jan 10:26:14 - [info] [remote-access:3ded0a56c6ab5471] Server: nodered02.remote-red.com InstanceHash: lxtanj4ngganddgxhicg6ig24mmo5szayv88mybma2ehgrwc5tpji2zr2axu5rdq
25 Jan 10:26:14 - [info] Started flows
(node:7852) [DEP0128] DeprecationWarning: Invalid 'main' field in 'C:\Users\nizar_n31aszd\.node-red\node_modules\node-red-contrib-azureiothubnode\node_modules\azure-iot-amqp-base\package.json' of 'main.js'. Please either fix that or report it to the module author
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:7852) [DEP0128] DeprecationWarning: Invalid 'main' field in 'C:\Users\nizar_n31aszd\.node-red\node_modules\node-red-contrib-azureiothubnode\node_modules\azure-iot-mqtt-base\package.json' of 'main.js'. Please either fix that or report it to the module author
25 Jan 10:26:14 - [error] [MySQLdatabase:database] Error: connect ECONNREFUSED 127.0.0.1:3306
25 Jan 10:26:14 - [info] [mqtt-broker:1c432e291f825d5c] Connected to broker: mqtt://mqtt.ci-ciad.utbm.fr:1883
25 Jan 10:26:14 - [info] [remote-access:3ded0a56c6ab5471] Using nodered02.remote-red.com on port 51472
25 Jan 10:26:14 - [info] [remote-access:3ded0a56c6ab5471] starting ssh process
25 Jan 10:26:19 - [info] [azureiothub:Azure] Connection to IoT Hub not established or configuration changed. Reconnecting.
25 Jan 10:26:19 - [info] [azureiothub:Azure] Connecting to Azure IoT Hub:
   Protocol: mqtt
   Connection string :HostName=testarduino.azure-devices.net;DeviceId=arduinotest1;SharedAccessKey=RklY5u4GRhf/53YDmbf3/AtHxMiTH3dGfAIoTNeyDOM=
25 Jan 10:26:19 - [info] [azureiothub:Azure] Connected to Azure IoT Hub.
25 Jan 10:26:19 - [info] [azureiothub:Azure] Message is pending. Sending it to Azure IoT Hub.
25 Jan 10:26:19 - [info] [azureiothub:Azure] Sending Message to Azure IoT Hub :
   Payload: [object Object]
25 Jan 10:26:19 - [red] Uncaught Exception:
25 Jan 10:26:19 - [error] TypeError [ERR_INVALID_ARG_TYPE]: The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received an instance of Object
    at new NodeError (node:internal/errors:406:5)
    at Function.byteLength (node:buffer:775:11)
    at publish (C:\Users\nizar_n31aszd\.node-red\node_modules\mqtt-packet\writeToStream.js:334:51)
    at Object.generate [as writeToStream] (C:\Users\nizar_n31aszd\.node-red\node_modules\mqtt-packet\writeToStream.js:34:14)
    at sendPacket (C:\Users\nizar_n31aszd\.node-red\node_modules\mqtt\lib\client.js:168:29)
    at storedPacket (C:\Users\nizar_n31aszd\.node-red\node_modules\mqtt\lib\client.js:224:5)
    at Store.put (C:\Users\nizar_n31aszd\.node-red\node_modules\mqtt\lib\store.js:42:5)
    at storeAndSend (C:\Users\nizar_n31aszd\.node-red\node_modules\mqtt\lib\client.js:219:24)
    at MqttClient._sendPacket (C:\Users\nizar_n31aszd\.node-red\node_modules\mqtt\lib\client.js:1234:7)
    at publishProc (C:\Users\nizar_n31aszd\.node-red\node_modules\mqtt\lib\client.js:649:14)
    at MqttClient.publish (C:\Users\nizar_n31aszd\.node-red\node_modules\mqtt\lib\client.js:659:74)
    at constructor.publish (C:\Users\nizar_n31aszd\.node-red\node_modules\node-red-contrib-azureiothubnode\node_modules\azure-iot-mqtt-base\lib\mqtt_base.js:122:43)
    at constructor.handle (C:\Users\nizar_n31aszd\.node-red\node_modules\machina\lib\machina.js:613:25)
    at Fsm.<computed> [as handle] (C:\Users\nizar_n31aszd\.node-red\node_modules\machina\lib\machina.js:466:63)
    at MqttBase.publish (C:\Users\nizar_n31aszd\.node-red\node_modules\node-red-contrib-azureiothubnode\node_modules\azure-iot-mqtt-base\lib\mqtt_base.js:240:19)
    at constructor.sendEvent (C:\Users\nizar_n31aszd\.node-red\node_modules\node-red-contrib-azureiothubnode\node_modules\azure-iot-device-mqtt\lib\mqtt.js:275:37)

The no connection will be related to the fact it is being crashed.

As you can see from this line, the cause of the problem is node-red-contrib-azureiothubnode

My first question is why are you using this? I am not certain it offers anything the built in MQTT nodes cannot do.

As for recovery, start node-red in safe mode and disable the azure mqtt nodes then deploy.

Use node-red --safe to start in safe mode.

thank you very much, that debug my Node-red, but do you have an idea how to connect the node-red with a devide from azure like azure IoT hub?

First result from google: Connecting Node-Red to Azure IoT Hub using MQTT nodes. | by Nikhil Kinkar | Medium

Any good?

Or perhaps https://azure.microsoft.com/en-us/blog/connecting-node-red-to-azure-iot-central/ ? (3rd search result)

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.