MQTT config and general questions

I have several pi's running MQTT and it all seems to work. Several weeks ago I saw a post where someone had trouble with MQTT disconnects and the answer seemed to be remove the broker from the pi and just use node red. I cannot find the post again and I may have been imagining things again but ......
As far as I can tell even if you have node red you have to have a broker. I use Mosquitto. Several days ago I cracked open a MQTT node and was surprised to see a whole slug of new config options. This after numerous updates over time from way back in the node red V1 days. Most new options having to do with MQTT V5. After a day of google I have seen a number of posts about V5 and on the mosquitto web site there is a post that states they recommend not to use V5 yet. So question one, what is the general recommendation about V5? Use it or no? I have been unable to find a broker for the pi that supports V5. Maybe that answers the first question?

I would use v5 if I needed it :grinning:

Mostly you probably don't.

But Mosquitto seems to support it OK and I've used it with Node-RED and v5 - though off the top of my head I can't remember why now. Maybe just a test. Oh, yes, that's right, I use v3.1.1 on my live Node-RED instance and v5 on my test instance. Both connected to the same Mosquitto broker.

In terms of repeated disconnects, the most common issue is accidentally having two different connections using the same client ID. So either don't set one or make absolutely certain it is unique.

MQTT is a very reliable and stable comms protocol and Mosquitto is second-to-none in terms of performance and low resource usage. The only problems I've ever had with it have been that they have inadvertently occasionally switched default settings which has meant that an upgrade of Mosquitto has broken the server.

You need a broker.

Node-red doesn't have a broker.

All the new options are to do with subscribing to multiple topics or brokers. (I haven't actually looked at them as I am a bit behind on updates)

So what is your question sorry?

Try this

  1. Need a broker installed. OK got that.
  2. Use MQTT V5? Seems to be up in the air.
    A note, I'm not having disconnects that was the reason for the one post I saw. My MQTT seems to work OK but in the interest of moving forward was looking at the new MQTT. By the way, I have not found where to install MQTT V5 from but will probably wait until it's a common install.

It comes automatically with Mosquitto (and all/most other brokers)

It's not experimental

You don't have to use the V5 protocol unless you want to

Node-RED MQTT nodes still default to V3.1.1
image

1 Like

That answer did not make sense to me either. I think the guy either mis-typed or was confused.

In fact there is a broker available in a node-red node, node-red-contrib-aedes (node) - Node-RED. Personally I avoid it as it has disadvantages, such as running in the node red process rather than a separate process, and not supporting Retained topics.

@cymplecy when I go into the node and select mqtt v5 the node never connects. My pi is totally up to date so I assumed the mosquitto broker didn't support V5. I must be doing something else wrong.

Go into a terminal and run
apt policy mosquitto
post the result here.

@Colin will do in a few hours, out and about and annoying wife by using phone.

1 Like

Here is an example of something that can only be done with MQTT v5 not v3.

It shows how you can use the new [request/response]((Understanding And Using MQTT v5 Request Response) model.

So you can now have a direct communications flow between endpoints using MQTT where the 2nd endpoint can respond to any source client. Previously, you would have had to roll-your-own data inside the payload and decipher that. An endpoint can, of course, be on any service (multiple Node-RED, NR and Python, ...) or indeed can be an IoT device or a web page using MQTT over Websockets.

Couldn't get a screen shot working

Installed: 1.5.7-1+deb10u1
Candidate: 1.5.7-1+deb10u1
Version table:
1.5.7-1+deb10u1. 500

Apart from the nifty responseTopic demo you did (and the one I did some time back), where V5 will be a big bonus is in the future when you have a stable running install, sending number values (not JSON) and realise you absolutely must have some additional data (like a 'timestamp' or 'gps-lat-lon' or 'device-owner') adding to the packet - however - you MUST NOT break the other 63 systems that expect a number value in the payload. This is where User Properties comes in very handy.

Also, another good feature you dont realise you need - until you do - is expiring retained messages. Imagine you publish every 5 mins the fill-level (retained) but the publisher breaks down or is offline for 6 hours - when a client connects, it will get a value that was last updated 6 hours ago. With Expiry set, the broker will throw the old retained message away after the specified time (probably best set to 6 minutes for this example).

Lastly, what will become more useful (in time) is the ability to auto parse the payload by checking the Content Type value.

Combining these feature together creates even more possibilities. e.g. suppose SERVER1 wants to send a control message to MQTTSERVER and expects a response in XML. and SERVER2 wants to send a control message to MQTTSERVER but can only handle JSON, they can both make use of the Content Type and Response Topic to ensure thats what they get.

1 Like

That's quite an old version (which probably doesn't offer V5 protocol)

But no need to change it unless you want to use any V5 features

I update my system often and I assumed it would update mosquiito to latest as well. Apparently not. So I went through the hoops to update mosquitto to latest and amazingly, got MQTT V5 to work. While I don't NEED the new features this was an exercise in learning. So, a few more new tid bits I can forget in a month.

2 Likes

You need at least v1.6.4 I think for MQTT v5 support.

Prompting me to start trying to build a MQTT Explorer like interface using uibuilder that supports the extra data for MQTT v5 :grinning:

Using Svelte because I need the exercise on it and I found a simple Svelte tree component that will hopefully do the job.

Looks like the otherwise excellent MQTT Explorer isn't going anywhere so this may actually be useful on several fronts: Learning more Svelte, properly documenting how to use Svelte with uibuilder, creating a basic svelte template for uibuilder, and creating a v5 aware MQTT explorer.

2 Likes

Yeah - its a big shame. I'm hoping a good fork appears.

I await with baited breath :clap::clap::clap:

Looks like 2.0.12 is latest version of mosquitto

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