# MQTT suddenly crashed

**URL:** <https://discourse.nodered.org/t/mqtt-suddenly-crashed/48544>\
**Category:** General\
**Created:** [18 July 2021 10:23 UTC](https://discourse.nodered.org/t/mqtt-suddenly-crashed/48544 "2021-07-18T10:23:54Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![nonomu1](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nonomu1/32/36095_2.png) [@nonomu1](https://discourse.nodered.org/u/nonomu1)\
**Post date:** [18 July 2021 10:23 UTC](https://discourse.nodered.org/t/mqtt-suddenly-crashed/48544/1 "2021-07-18T10:23:54Z")

</div>

Hi all,

We have a machine protocol that connect to ActiveMq via MQTT nodes.  
we are communicating via topic exchange.  
We are facing 2 main issue:

1. On suddenly disconnect from ActiveMQ node-red crashes
2. Sometimes MQTT nodes showing connected but messages not recieving - after a long time without messages exchange.

For general info: I'm using a docker with latest image of nodered/node-red:minimal

Did someone faced this issues?

_ **Finally i was able to reproduce the errors on terminal:** _\*

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/0/e0f358a90587349e3f609885f866cb09574d2c17.png)

This happens when i'm using the default TTL : 60s and not V on clean session.  
"Uncaught exepction" : this current node-red using only 1 MQTT node and 1 debug node.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 July 2021 10:40 UTC](https://discourse.nodered.org/t/mqtt-suddenly-crashed/48544/2 "2021-07-18T10:40:27Z")

</div>

The first thing to do is to run node-red in a terminal and see what it shows when it crashes. Post the full output from the terminal here please, including the node-red startup.

**[Edit]** For question 2 install MQTT explorer and connect it to the broker, then you will see whether it is node-red that is the problem.

---

<div class="post-metadata">

**Author:** ![edje11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/edje11/32/572_2.png) [@edje11](https://discourse.nodered.org/u/edje11)\
**Post date:** [18 July 2021 11:27 UTC](https://discourse.nodered.org/t/mqtt-suddenly-crashed/48544/3 "2021-07-18T11:27:48Z")

</div>

Have a look with MQTT explorer at your mqtt broker, it looks like it gets floods with to much messages.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [18 July 2021 12:52 UTC](https://discourse.nodered.org/t/mqtt-suddenly-crashed/48544/4 "2021-07-18T12:52:08Z")

</div>

> [@nonomu1](#):
>
> ActiveMQ

A message queue server should NEVER crash! That is a severe failure of your infrastructure. MQ's should be one of the most stable services that you have since their whole purpose is to act as "glue" between systems.

However, I note that ActiveMQ is one of Apache's creations and written in Java - far from my favourite language and something that I personally advise people to avoid if at all possible.

Java has a number of ongoing structural issues that make it a rather expensive platform to maintain. For example, running a Java-based application on a device with limited memory is quite likely to result in issues. Java needs careful memory management both from a developer perspective and from an operational one.

If you are only using ActiveMQ for MQTT, I strongly advise you to move to Mosquitto instead. It is rock solid and uses minimal resources.

Otherwise, carefully check the memory utilisation of ActiveMQ.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 July 2021 13:25 UTC](https://discourse.nodered.org/t/mqtt-suddenly-crashed/48544/5 "2021-07-18T13:25:54Z")

</div>

I understood that it is node-red that is alleged to be crashing, not the broker.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [18 July 2021 14:20 UTC](https://discourse.nodered.org/t/mqtt-suddenly-crashed/48544/6 "2021-07-18T14:20:22Z")

</div>

Ah, my bad, I misread that.

I would still check memory utilisation though since Java is such a hog.

---

<div class="post-metadata">

**Author:** ![nonomu1](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nonomu1/32/36095_2.png) [@nonomu1](https://discourse.nodered.org/u/nonomu1)\
**Post date:** [19 July 2021 08:29 UTC](https://discourse.nodered.org/t/mqtt-suddenly-crashed/48544/7 "2021-07-19T08:29:18Z")

</div>

Hi Colin,

It happens on docker containers.  
I'm trying to reproduce the issue again.  
Something weird that if i use the default config of MQTT nodes, so i do'n't get the error/connections status from the node.  
If i change to keep-alive to 0 and use clean session , i suddenly get the:  
client error Error: connect ECONNREFUSED  
and timeout.

---

<div class="post-metadata">

**Author:** ![nonomu1](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nonomu1/32/36095_2.png) [@nonomu1](https://discourse.nodered.org/u/nonomu1)\
**Post date:** [19 July 2021 08:30 UTC](https://discourse.nodered.org/t/mqtt-suddenly-crashed/48544/8 "2021-07-19T08:30:43Z")

</div>

> [@edje11](#):
>
> MQTT

For question 2 : Unfortunately i can't because it's connected to out source company ActiveMQ.

---

<div class="post-metadata">

**Author:** ![nonomu1](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nonomu1/32/36095_2.png) [@nonomu1](https://discourse.nodered.org/u/nonomu1)\
**Post date:** [19 July 2021 08:33 UTC](https://discourse.nodered.org/t/mqtt-suddenly-crashed/48544/9 "2021-07-19T08:33:15Z")

</div>

Hi there,

Thank you for the reply.  
The ActiveMQ is used by outsource company that we are sending messages to.  
We can't change to current infra.  
As i see node-red is pretty stable but we have the above issues once a while.

Thx, Nono

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [19 July 2021 09:31 UTC](https://discourse.nodered.org/t/mqtt-suddenly-crashed/48544/10 "2021-07-19T09:31:11Z")

</div>

> [@nonomu1](#):
>
> If i change to keep-alive to 0

Why would you want to do that? I don't know if that is even legal.

Just because you are connecting to an outsourced broker does not stop you using MQTT Explorer. Run it on your PC and connect to the broker, then you will see whether problem 2 is in node-red or in the publish or broker.

> [@nonomu1](#):
>
> _ **Finally i was able to reproduce the errors on terminal:** _ \*

We need to see the full log, there should be more after that. Copy/paste the text please, not a screenshot. Use the `</>` button at the top of the forum entry window when pasting it in.

---

<div class="post-metadata">

**Author:** ![nonomu1](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nonomu1/32/36095_2.png) [@nonomu1](https://discourse.nodered.org/u/nonomu1)\
**Post date:** [19 July 2021 09:46 UTC](https://discourse.nodered.org/t/mqtt-suddenly-crashed/48544/11 "2021-07-19T09:46:13Z")

</div>

I will look into the MQTT Explorer.  
Regards the keep alive i just wanted to let you know that it current default settings i don't recieve events messages from MQTT , only if i change i recieve MQTT events messages. (at least in the logs)  
This is the logs:

```auto
2021-07-19 11:34:21	
npm ERR! /data/.npm/_logs/2021-07-19T08_34_21_554Z-debug.log
2021-07-19 11:34:21	
npm ERR! A complete log of this run can be found in:
2021-07-19 11:34:21	
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-07-19 11:34:21	
npm ERR! Failed at the node-red-docker@1.3.5 start script.
2021-07-19 11:34:21	
npm ERR! 
2021-07-19 11:34:21	
npm ERR! Exit status 1
2021-07-19 11:34:21	
npm ERR! node-red-docker@1.3.5 start: `node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS "--userDir" "/data" "node-red" "flows.json"`
2021-07-19 11:34:21	
npm ERR! errno 1
2021-07-19 11:34:21	
npm ERR! code ELIFECYCLE
2021-07-19 11:34:21	
    at TCP.onStreamRead (internal/stream_base_commons.js:111:27)
2021-07-19 11:34:21	
19 Jul 08:34:21 - Error: read ECONNRESET
2021-07-19 11:34:21	
19 Jul 08:34:21 - [red] Uncaught Exception:
2021-07-19 11:33:44	
19 Jul 08:33:44 - [info] [mqtt-broker:baff5da1.7789b] Disconnected from broker: mqtt:// *******
2021-07-19 11:25:35	
19 Jul 08:25:35 - [info] [mqtt-broker:baff5da1.7789b] Connected to broker: mqtt:// *****
2021-07-19 11:22:50	
19 Jul 08:22:50 - [info] [mqtt-broker:baff5da1.7789b] Disconnected from broker: mqtt:// ******

```

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [19 July 2021 09:52 UTC](https://discourse.nodered.org/t/mqtt-suddenly-crashed/48544/12 "2021-07-19T09:52:50Z")

</div>

Unfortunately that doesnt give us a lot to go on, but that is often the case with uncaught exceptions.

Just to confirm, this was with just an MQTT and inject node?

There must be some code path that can lead to the error handler being missed. if there's any more information/observations you can share about when this happens (for example, the log suggests this happens a while after a disconnect?) That would be helpful.

Did you mentioned this started happening on 1.3.5? If so, what previous version were you using?

---

<div class="post-metadata">

**Author:** ![nonomu1](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nonomu1/32/36095_2.png) [@nonomu1](https://discourse.nodered.org/u/nonomu1)\
**Post date:** [19 July 2021 10:27 UTC](https://discourse.nodered.org/t/mqtt-suddenly-crashed/48544/13 "2021-07-19T10:27:20Z")

</div>

Hi Nick,

Old version was 1.2.2 (i'm not completely sure that the error don't accour there)  
The process was to shutdown the ActiveMQ server and then waiting a while , and sudden crash accours.  
Like mentioned when i using the default settings i don't get the Event logs , i tried to change (now i can't reproduce it , but when i changed the keep alive to 0 suddenly dissconnections and reset and other events are being logged)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [19 July 2021 10:57 UTC](https://discourse.nodered.org/t/mqtt-suddenly-crashed/48544/14 "2021-07-19T10:57:47Z")

</div>

> [@nonomu1](#):
>
> when i using the default settings i don't get the Event logs

What do you mean by Event logs? Is that the question 2 in your first post?

---

<div class="post-metadata">

**Author:** ![nonomu1](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nonomu1/32/36095_2.png) [@nonomu1](https://discourse.nodered.org/u/nonomu1)\
**Post date:** [21 July 2021 16:20 UTC](https://discourse.nodered.org/t/mqtt-suddenly-crashed/48544/16 "2021-07-21T16:20:05Z")

</div>

The events of reconnections or ecconect refused and etc of MQTT

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [19 September 2021 16:20 UTC](https://discourse.nodered.org/t/mqtt-suddenly-crashed/48544/17 "2021-09-19T16:20:57Z")

</div>

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