MQTT Nodes stopped working

Very strange. on one instance of node red on a raspberry pi all MQTT nodes stopped working earlier. All are showing "disconnected". From a laptop running node red I can connect to all the MQTT servers.

I would appreciate any recommendations how to debug this.

Node red v1.2.5
Node v8.16.0
npm 6.13.4

mmm. many questions to ask..
so you have more than one MQTT server ?
Are your MQTT instances running in which machine , same on as your Node-RED instance ?
How do you configure the MQTT server in the node , via ip adddress or host name ?

First thing i would check is if the machine hosting MQTT changed it ip address.

Hi @Andrei, 3 servers on different machines all configured with ip address, including the problem instance. I can connect from all the other instances to the MQTT server on the problem machine. The ip address has not changed!

Good, so we can discard ip connectivity issues between machines.

Well, the second thing that comes to my mind is checking the status os the MQTT service. Assuming you have installed mosquitto under Raspbian you would issue the command: systemctl status mosquitto

odroid@odroid:~$  systemctl status mosquitto
â—Ź mosquitto.service - LSB: mosquitto MQTT v3.1 message broker
   Loaded: loaded (/etc/init.d/mosquitto; generated)
   Active: active (running) since Wed 2020-10-21 10:51:20 -03; 1 months 4 days ago

Everything is fine with the MQTT service.

An issue was reported earlier this week regarding the MQTT nodes and Node 8.

We updated to the latest mqtt module in 1.2.5 - looks like it breaks on Node 8. Need to investigate properly - may need to do 1.2.6 with a reverted version of the mqtt module, unless we can find a way to workaround the issue to keep node 8 going...

The alternative is to upgrade off Node 8 (which reached its end of life 10 months ago).

Thanks @knolleary, the machine was running 1.2.1 and had the same problem, I updated to 1.2.5 in the hope of getting rid of the problem.

How can I update node?

I have this when starting node red:

ReferenceError: URL is not defined
    at Object.connect (/usr/lib/node_modules/node-red/node_modules/mqtt/lib/connect/index.js:64:18)
    at MQTTBrokerNode.connect (/usr/lib/node_modules/node-red/node_modules/@node-red/nodes/core/network/10-mqtt.js:245:40)
    at MQTTBrokerNode.register (/usr/lib/node_modules/node-red/node_modules/@node-red/nodes/core/network/10-mqtt.js:221:22)
    at new MQTTOutNode (/usr/lib/node_modules/node-red/node_modules/@node-red/nodes/core/network/10-mqtt.js:504:29)
    at Object.createNode (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/flows/util.js:493:31)
    at Flow.start (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/flows/Flow.js:194:48)
    at start (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/flows/index.js:345:33)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
ReferenceError: URL is not defined
    at Object.connect (/usr/lib/node_modules/node-red/node_modules/mqtt/lib/connect/index.js:64:18)
    at MQTTBrokerNode.connect (/usr/lib/node_modules/node-red/node_modules/@node-red/nodes/core/network/10-mqtt.js:245:40)
    at MQTTBrokerNode.register (/usr/lib/node_modules/node-red/node_modules/@node-red/nodes/core/network/10-mqtt.js:221:22)
    at new MQTTOutNode (/usr/lib/node_modules/node-red/node_modules/@node-red/nodes/core/network/10-mqtt.js:504:29)
    at Object.createNode (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/flows/util.js:493:31)
    at Flow.start (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/flows/Flow.js:194:48)
    at start (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/flows/index.js:345:33)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)

I have been keeping watch the work being done on MQTT (for MQTT V5 interests) & this is a recent issue (somewhere between V4.2.2 and v4.2.5)

I has been reverted in the latest release of MQTT.js V4.2.6

If you would be willing to try it out and feedback?...

  • stop node-red
  • CD to your node-red folder
  • npm install mqtt@latest
  • start node-red

@Steve-Mcl unfortunately no improvement :thinking:

hmmmm

what do you get if you run

npm outdated

in your node-red directory?

Package                                 Current  Wanted  Latest  Location
node-red-contrib-countdown                1.3.0   1.3.1   1.3.1  node-red-project
node-red-contrib-influxdb                 0.4.1   0.4.1   0.5.1  node-red-project
node-red-contrib-moment                   3.0.3   3.0.3   4.0.0  node-red-project
node-red-contrib-queue-gate               1.4.0   1.4.0   1.5.1  node-red-project
node-red-contrib-schedex                 1.10.2  1.10.3  1.10.3  node-red-project
node-red-contrib-stackhero-influxdb-v2    1.0.1   1.0.3   1.0.3  node-red-project
node-red-contrib-theme-midnight-red       1.0.5  1.0.29  1.0.29  node-red-project
node-red-node-email                       1.7.8  1.7.11   1.8.2  node-red-project
node-red-node-pi-gpio                     1.1.1   1.1.1   1.2.1  node-red-project
node-red-node-ping      

@Steve-Mcl you'll need to clarify what you mean by "node-red directory".

You are referring to the directory that node-red is installed in - not the .node-red user directory.

Given MQTT have rolled back the change as of 2 hours ago, we'll ship 1.2.6 with the updated dependency to fix this problem.

Yes, sorry, of course, should have been specific.

@ghayne could you try npm outdated from within the directory node-red is installed in please (not your user .node-red directory)

Of course (but would be nice to know if it actually is fixed & @ghayne can get moving again in the meantime :slight_smile: )

/usr/bin/npm outdated gave no results.

Shoulkd I do /usr/bin npm install mqtt@latest?
as I did .node-red/npm install mqtt@latest earlier?

No

Thats not where node-red is installed.

/usr/lib/node_modules/node-red should be where it is (usually)

go in there and do npm outdated - i suspect you are on MQTT V4.2.5

Package   Current  Wanted  Latest  Location
fs-extra    8.1.0   8.1.0   9.0.1  node-red
semver      6.3.0   6.3.0   7.3.2  node-red

yes

cd /usr/lib/node_modules/node-red/node_modules
npm ls | grep mqtt

sudo npm i mqtt@latest

what Dave said ^

Sorry for the runaround :frowning: