[Fun Exercise]Make an MQTT broker in Node-RED

I use aedes - but I'm intrigued to see how this goes - hence my excitement at the start.

It really is just for the fun of doing it :slight_smile:

1 Like

I was just looking at that, or rather the aedes.js project - good to know that there is already an integration for Node-RED.

I also found the mqtt standard - I bet the butler did it in the end!

Thanks for the inspiration :+1:

1 Like

Yeah looks like a nice easy read :wink:

Not Note that aedes is missing a number of features such as Retained topics (unless it has been added recently). Mosquitto is so simple to install and setup, at least on Linux, that it really isn't worth using aedes.

2 Likes

Indeed, I installed in about 3mins on a raspberry pi but .... I had to go into a shell and terminal window.

I'm on the I-want-to-do-everything-in-node-red trip and therefore I really dislike leaving the soothing surroundings of nodes, events and wires! It would definitely only be for educational purposes.

Btw Aedes also took about 3mins to install but added 161 (sic!) additional packages to Node-RED!?!?

2 Likes

Does anyone know if the Aedes got fixed? There was an error when you deployed.

Well section 2 MQTT Control Packet format - is the main / most useful section (IMHO) - and (spoiler) no it wasn't the butler - it was Andy S-C, though our own @knolleary has implemented it a fair few times on various platforms :slight_smile:

1 Like

FYI the Blockly code to read topic length and then extract its name.

and the JS it produces for those of you who don't speak Blockly :slight_smile:

var rcvdPayload, topicLength, topicName;


rcvdPayload = (msg['payload']);
topicLength = 256 * (rcvdPayload[5 - 1]) + (rcvdPayload[6 - 1]);
topicName = rcvdPayload.slice(6, 6 + topicLength);
topicName = (topicName.toString("utf8"));
msg['mqttPacket']['subscribe']['topicName'] = topicName;
node.status({fill:"blue", shape:"ring", text:([topicLength,':',topicName].join(''))});
return msg;

Note: Blockly is 1-based indexing as all good languages are......

2 Likes

indeed Aedes does install everything including the kitchen sink... and of course is on the same thread as the rest of Node-RED (as node.js is (mostly) single threaded) so yeah uuurgh....

One little issue that's come up is that although the switch node will accept non-decimal numbers, it highlights the box red as if they are invalid
image

1 Like

probably worth raising as a real issue - at least for discussion - as it is probably the same across all numeric typed inputs.

1 Like

Wow! Blockly seems to be lego mindstorms for grown ups! I guess it would be fun project to reverse engineer the lego mindstorm protocol, and then use blockly in Node-RED to control lego mindstorm :thinking:

It's weird how everything is bracket'ised but that line made me think back to BODMAS - there were I would have used a brackets, Blockly doesn't!

Has been noted ... I created myself a flow to remind me of the technology.

The transcoding from Blockly to JS is done in a very industrial way. :slight_smile:
Just needs to always work - doesn't need to look nice.

Never look how sausages are made :slight_smile:

3 Likes

The main thing to note about that I think is that its performance is abysmal compared to the tiny service that is Mosquitto. This is not really its fault, just a consequence of doing low-level things in a high-level language I think.

Of course this may not matter to everyone. :slight_smile:

1 Like

Wait till you see the performance of mine then :slight_smile:

3 Likes

I use aedes for interprocess on the same machine, I wouldn't dream of the practice for bigger projects that involve different hosts :scream:

2 Likes

Don't do. There's already a PR posted, waiting to be approved, that addresses this "feature":

2 Likes

I'll close the issue I raised

1 Like

(Thanks for raising it though;-) )

1 Like