I have a question about setting mqtt

I am trying to receive a message using node red mqtt on the raspberry pi.

I ran well without mqtt problem in node red, but there is one problem.

Mqtt messages suddenly become unsubscribed.

For example, when booting from the Raspberry Pi,
node red is automatically executed and sensor data is received through the flow.
However, after about 3 to 6 hours,
the mqtt message cannot be subscribed and sensor data cannot be received from node red.

I check mqtt status and it says that it is active,
but when I check mosquitto_sub -t -v'#' in cmd command window, there is no message.

So, when I reboot the Raspberry Pi again, the sensor data comes in without any problems.

Is there any way to solve a case like this?
For example, is there a flow method that can give a command in node red to reboot the raspberry pi if mqtt message is not received, or is there a way to configure the raspberry pi?

what kind of sensor are you using?

In node red configure an inject node feeding a value to an mqtt Out node with a topic of, for example, "test", and an mqtt In node subscribing to that topic and feed that into a debug node. Check that when you click the inject button that the value appears in the debug output. Wait till your sensor stops and see if the test still works. If it does then that shows that node red and the mqtt broker are still going ok. If it does then probably the problem is the sensor or its connection to mqtt.

I don't think it's a sensor problem.
In the case of the sensor, it works properly on a directly connected platform.
The problem is that when connecting mqtt on the Raspberry Pi, publishing suddenly stops after 3 to 6 hours.

Is there a case where mqtt is suspended due to overload due to too many messages?

This is a sensor from Atlas Scientific.

Until you run the test I suggested, or something similar, you cannot be certain where the problem is.

Also tell us what mqtt broker you are running and where it is running and how the sensor connects to mqtt.

Also what do you do to get it running again?

Well I see.
As you said, let's do a test.
I will test and post again.

You didn't answer those questions.

Does the atlas box talk to MQTT to send messages?

What could be happening is the TCP connection between mqtt and the device is timing out.

I had a similar thing happening with a ESP which was monitoring a tank level sensor... it overflowed a few times and caused a big mess.

What I ended up doing to fix it is poll the sensor rather then waiting for the sensor to send a status update.

If that is happening I believe it implies a bug in the device or in the broker. But we are pretty much in the dark until we are given more information.

If that is the case then the LWT message should get fired on the broker.

1 Like

hi,(first, sorry about my english) i had a similar problem with node red and mqtt communication.
i had connected my sensor to Arduino (or ESP) and then i used the pubSubClient library for mqtt, ran mqtt broker on my raspberry pi, but after a time, the conexion lost.

You can check your code on device (Pub) if you had the loop() function. this function should:

Nick Olleary. - "This should be called regularly to allow the client to process incoming messages and maintain its connection to the server."

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