How to Install and Run The Aedes MQTT Broker on Node-Red

aedes-broker-imageRather than use an external broker like mosquitto with node-red you can install the Aedes node which is a MQTT broker written in node.js.

Because Aedes isn’t part of the core nodes you need to install it using the npm package manager or through the Node-red Admin control panel.

Note: Aedes replaces the Mosca broker.



Aedes Install Using Node-red Admin

In the node-red admin go to Settings and manage Pallette.

node-red-settings

Click on the install tab and search for aedes.

aedes-broker

 

aedes-broker-location

After the install you should find a new node called aedes under the network categories.

Drag and drop on the Canvas to use.

Aedes Node Configuration

The node properties has two tabs connections and security,and with very few settings.

The main tab is show below:

aedes-broker-configuration

 

You need to set the ports for standard MQTT and MQTT over websockets if used.

There is an option to enable SSL and if you do that then your are able to upload certificates.

You will need to upload the server.crt and the server.key files as shown in the screen shot below:

aedes-ssl

If you enable SSL then it is enabled for MQTT and MQTT over websockets, if configured. In the above screenshot the SSL port is 1883. So the possible configurations are:

  • MQTT + Websockets
  • MQTT (SSL)+ Websockets(SSL)

That means that you cannot run MQTT and MQTT(SSL) on the broker. You also need to have the MQTT port configured but websockets is an option.

The security tab contains options for username and password. These fields I understand are for the mongodb database,and you can usually leave them blank even when using the database.

The mongo database is used for persistent data and is usually as shown in the screenshot.

mongodb://127.0.0.1:27017/MQTT

Note: If it appears greyed out then it is not being used.

Persistent data stores unsent messages,subscribes and retained messages so they are remembered if the server is restarted.

To use it you will need to have the mongodb server installed on your system.

mongosb-nodes

Important Note: This isn’t the mongodb node. The node is a connector to a database server and not the server itself.

You will need to install the mongodb database server separately it is not a node-red node.

Testing The Install

You can use any MQTT client for testing the broker.The easiest is to use the MQTT input and output nodes.

Here is a screen shot of my test flow:

aedes-broker-testing

Here is the flow code which you can import into your own flow:

Video- How to Install The Mosca MQTT Broker on Node-Red

Performance

In case you are worried about performance I did a quick check using my node-red broker tester with a message rate of 100 messages/sec and it didn’t record any errors. The screenshot below show the result

aedes-performance

Note The Aedes broker was also running on the same node-red instance as the test software.

Aedes vs Mosquitto

Aedes is a a very basic broker that lacks many of the features of mosquitto e.g message size restrictions, ACL (access controls lists), bridging etc.

Having said that it is an ideal choice on a local network/home network where non of the these advanced features aren’t required especially when node-red is also being used.

Summary

The Node-Red Aedes node replaces the Mosca node is a nodejs broker, and is useful for testing, it may also be useful for small home automation networks.

It is not really suitable for a production environment as it lacks many of the features like ACL (access control lists), authentication, message limits) that the mosquitto broker has.

However the message throughput seems to be very good.



Related Tutorials and Resources

Click to rate this post!
[Total: 3 Average: 5]

54 comments

  1. Hi Steve,
    I’ve wanted to make a safe app for live readings of data.
    For that I’ve wanted to use Aedes MQTT Broker with WebSockets enabled.
    The safety part is a problem. When I add certificates the app is not loading any data and console shows this message:
    Connection failed, ERROR: AMQJSC0001E Connect timed out.
    WebSocket connection to ‘wss://192.168.1.213:1884/mqtt’ failed:
    Paho.MQTT.ClientImpl._doConnect @ mqttws31.js:979
    Paho.MQTT.ClientImpl.connect @ mqttws31.js:849
    Client.connect @ mqttws31.js:1799
    init @ Temperatura_BIURO_FREEEN_TLS.html:90
    onload @ Temperatura_BIURO_FREEEN_TLS.html:180

      1. Hi Steve,

        Yes. It worked without ssl and I’ve used test.mosquitto.org to test the connection and it worked.
        The app is launched from a local file so I’ve tested it by enabling the ssl in the file and I’ve connected the app to the test broker. When I’ve checked the connection everything was fine.
        Now when I use Aedes there is a problem that it won’t connect.

  2. Hi, more info as requested:
    Installation from the Palette failed, the log stated that Aedes required NodeJS 14 or more. Tried to upgrade Node-Red using their script, but despite using the –force14 option, it refused to upgrade NodeJs.

    cd ~/.node-red
    bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) –node14

    But node -v still showed v12.22.12

    This had appeared among various error messages:
    Node red installation high severity CVE (Multer)
    Googling gave the result mentioned, so stopped Node-red and
    npm i multer@1.4.4-lts.1
    Ran the Node-red update script, again with the –force14 option
    Now:
    node -v v14.19.3
    npm -v 6.14.17
    And finally node-red-contrib-aedes installed OK.

  3. I had used this in the past, but last night it refused to install, despite updating the Node-Red install. It requires Node.JS v14, but NR refused to update from v12 despite using the –force14 option in the update script.

    The very last comment here: https://discourse.nodered.org/t/node-red-installation-high-severity-cve-multer/63892/5 resolved this issue, allowing the update script to run successfully. Maybe this will help another struggler with the same prob.

  4. Hi steve:
    i met a problem. I used aedes node as MQTT over websocket broker, and my websocket node can connet to the broker. But when I inject the node, the websocket node will show disconnected and after a while it will connected again. How can I fix that?
    best,
    J

    1. Hi
      Are you using the websockets node from the pallete. If so this is incorrect as you need a MQTT input. Use an mqtt out node configured for websockets.
      Rgds
      Steve

      1. I use both websocket output and websocket input. Do you mean I should use mqtt out node to publish message and use websocket input node to receive message?

  5. Nice tutorial.
    I would love to understand how you got the node-red broker tester to work. Looks like it’s built on top of node-red as well.
    Is there any tutorial for it somewhere?

    Trying to test a broker running on a pi.

    Thanks.

    1. Hi
      I’d forgotton about those flows. I just found them I must have started work on them and stopped. They appear to work but they aren’t finished if you want to try them I will email them just let me know.
      Rgds
      Steve

    1. I found the problem.
      When I dropped the mqtt node onto the canvas, the server in the properties was 192.168.1.91:1883
      I guess it is a default ip address
      I’ve now changed it to 127.0.0.1:1883

      8 Mar 18:16:33 – [info] Server now running at http://127.0.0.1:1880/
      8 Mar 18:16:33 – [info] Starting flows
      8 Mar 18:16:33 – [info] Started flows
      8 Mar 18:16:33 – [info] [aedes broker:aedes Broker] Binding aedes mqtt server on port: 1883
      8 Mar 18:16:54 – [info] [mqtt-broker:e21e4642.c12f6] Connection failed to broker: mqtt://192.168.1.91:1883
      8 Mar 18:17:30 – [info] [mqtt-broker:e21e4642.c12f6] Connection failed to broker: mqtt://192.168.1.91:1883
      8 Mar 18:18:06 – [info] [mqtt-broker:e21e4642.c12f6] Connection failed to broker: mqtt://192.168.1.91:1883
      8 Mar 18:18:08 – [info] Stopping flows
      8 Mar 18:18:08 – [info] [aedes broker:aedes Broker] Unbinding aedes mqtt server from port: 1883
      8 Mar 18:18:08 – [info] Stopped flows
      8 Mar 18:18:08 – [info] Starting flows
      8 Mar 18:18:08 – [info] Started flows
      8 Mar 18:18:08 – [info] [aedes broker:aedes Broker] Binding aedes mqtt server on port: 1883
      8 Mar 18:18:08 – [info] [mqtt-broker:e21e4642.c12f6] Connected to broker: mqtt://127.0.0.1:1883

  6. Hi there , was just playing with aedes broker, i´m used to mosquitto where i make bridge connections , saw something mentioned in aedes documentation related to bridge connections but not regarding node-red .
    Is it configurable somewhere or is it not present ??

    Thank you!

  7. Handy to have a broker running on the same machine,as always looking great.
    Would be nice to have a how-to part on non mongo dabases like sqlite .i cant find any info on that.

  8. Hello Steve! I’m created an virtual machine on Oracle Cloud with Node-RED. I’m using Aedes Broker. The WS Port of Broker is set to 8888. On property Server on my MQTT IN it’s defined as “ws://PublicIP:8888/mqtt”, but I couldn’t connect with Broker Server.
    I’m tryng connect my device with Tasmota firmware to Broker Server by MQTT.

  9. Hello, all right, I’m Luciano. I created my account on the IBM cloud and created the nod-red application through it, I’m trying to make the mosquito broker mqtt work on nod-red and nothing happens. Just a question, for it to work and will I have to have a local server like respbarry pi?

        1. In my project I’m using tasmota esp8266-12E, I want to control it using IBM Cloud and Node-Red, I don’t have MQTT installed locally, I did it according to your video, but even so node-red doesn’t connect as your example.

          1. Hi
            So you have node-red with aedes installed in the cloud is that correct. I assume your esp is local is that correct. Is the problem that the esp isn’t connecting to the clod broker?

  10. There is a new MQTT broker node for Node-Red called node-red-contrib-aedes which uses aedes.js under the hood.
    Node-red-contrib-mqtt-broker was based on mosca.js which is not supported anymore. The Mosca team decided to stop the develoment and created Aedes instead.
    Have a look and let me know if it works for you.

    1. Martin
      Tks for the info. I was aware of it but haven’t looked at it for a while I will try it out.
      Rgds
      Steve

  11. Hi, I managed to install the broker correctly thanks to this tutorial and made the test with the debug node. My only doubt is, how can I make this work with a device connected on a different network? Which address do I have to use on that case?

    1. You use the IP address of the machine running node red.Type ipconfig (windows) or ifconfig (linux) at the command line for the ip address
      Rgds
      Steve

  12. Hi, I want to send the data of Temperature sensor from ESP8266 to node red. I am using Mosca MQTT broker in node red and using windows operating system make this thing work but due to some issue, I am not able to send the data from esp8266 to Mosca MQTT broker in Node-Red.
    Any suggestion on this will be a great help.

    1. I use RPI and Dht sensors, how can i connect the sensors to Mosca MQTT broker, and obtain data from them ?

      1. Firstly I would use the aedes broker. It replaces the mosca broker and is being updated.
        All you then need to do is to enter the broker address into the sensors and send data. You will then need a client to subscribe and read the data. You can use node-red MQTT node to do that
        rgds
        Steve

          1. Martin
            Sorry I don’t use those sensors so couldn’t really say but they must have some kind of configuration file.
            Can you send me the code your are using to read the values. Use the ask-steve page to send it
            Rgds
            Steve

  13. Hello everyone!
    I made all the steps, everything is ok.
    I install the mongodb server (2.4.10), but i need help to setup the mongodb database server
    and connect to my broker.
    I don’t know how to do this, if anyone can help me!!!

    Thank you.

    Nick

  14. Steve
    I have tried using Mosca on Node Red but the system crashes.
    I get an error: Uncaught exception Type error;
    “cannot set property listening or # server which has only a getter”
    then it enters a “failed state” and goes into a rebooting loop.
    I lost the entire program and had to start fresh install.
    Have you heard of any issues with Mosca?

    1. Thats what I thought but when I tested it it didn’t work that way. It did work on the mongodb database fro remote access.

Leave a Reply

Your email address will not be published. Required fields are marked *