• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mosquitto MQTT Broker
#1
We have uploaded a new Docker image that turns your netPI into an MQTT broker: https://hub.docker.com/r/hilschernetpi/n...tt-broker/
You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply
#2
Hello Armin, I hope you're doing alright, I am just getting familiar with NetPI, I have some questions but I am going to start asking about Mosquitto MQTT Broker Docker container, the link you shared above does not exists anymore https://hub.docker.com/r/hilschernetpi/n...tt-broker/. I found a Github link: https://github.com/HilscherAutomation/ne...qtt-broker but it doesn't work.

is there any other option to install Mosquitto container on NetPI?, besides I would like to know if there is a Docker container for NIOT-E-NPIX-4DI4DO or how can I map this I/O Module thru Node-Red?

Thanks
Carlos
  Reply
#3
Hello Carlos,

you are right the Docker image is no more.

The reason why I decided to remove the Hilscher docker image for Mosquitto is quite simple. The organizsation Mosquitto itself offer a very official Docker image a long time ago under https://hub.docker.com/_/eclipse-mosquitto. So hence it does not make sense for Hilscher to offer it.

So the image to load is "eclipse-mosquitto". As you can read it on the page you need to add the ports 1883:1883 and 9001 :9001 to make it available to the "outside world".

If there is something you want to change in the mosquitto.conf file then you can open a console "/bin/ash"

   

in netPI's Docker web GUI and make your edits then usig the editor vi for example

   

Thx
Armin
You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply
#4
Dear Armin,

I am trying MQTT communication using netPI.
I deployed eclipse-mosquitto.
I am using "mqtt in" and "mqtt out" nodes in Node-Red.

But, status indicator below the nodes shows 'connecting', not 'connected'.

If you have any concerns, could you give me some advice?

Best regards,


Attached Files Thumbnail(s)
                   
  Reply
#5
Well for a better view I recommend to all MQTT users to install the tool MQTT-Explorer http://mqtt-explorer.com/ under windows (instead of Node-RED).

This tool is for free and much better to explore a running MQTT broker since it monitors ALL topics at once.

As next I installed the same eclipse-mosquitto:latest as you did. I also mapped the ports 1883 and 9001 ... and guess what ... the MQTT broker is not reachable via MQTT Explorer. So there seems to be a general problem with the latest version

When you click on the container and watch the log file it says:

Code:
1614766138: mosquitto version 2.0.7 starting
1614766138: Config loaded from /mosquitto/config/mosquitto.conf.
1614766138: Starting in local only mode. Connections will only be possible from clients running on this machine.
1614766138: Create a configuration file which defines a listener to allow remote access.
1614766138: Opening ipv4 listen socket on port 1883.
1614766138: Opening ipv6 listen socket on port 1883.
1614766138: Error: Address not available
1614766138: mosquitto version 2.0.7 running

"Starting in local only mode .Connections will only be possible from clients running on this machine" ? I don't know what this means right now. Maybe this is the explanation why it does not reachable from remote machines. 

I think on the MQTT broker landing page https://hub.docker.com/_/eclipse-mosquit...escription you will find more about this "local" mode. At the moment I am clueless. Earlier version worked well and with no problems at all.

Thx
Armin
You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply
#6
Well I read more details about the very latest version of Mosquitto with a breaking major change due to security reasons here:

https://mosquitto.org/documentation/migrating-to-2-0/

This change will have influence on the very latest version of Mosquitto Docker image version 2.x as well and explains, why the images does not work right away. I suppose after deploying the docker container, you need to edit the configuration file in the container manually. 

Of course it is always possible to load instead of the "eclipse-mosquitto:latest" = 2.x version the old version 1.x with "eclipse-mosquitto:1.6.13" instead
You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply
#7
I got it working now also with version 2.x.

Based on the documentation at https://mosquitto.org/documentation/migrating-to-2-0/ I added two lines additionally in the mosquitto configuration file in the container named

Code:
/mosquitto/config/mosquitto.conf

The two lines are
Code:
listener 1883
allow_anonymous true

Then I restarted the container and everything went well.

P.S.: I saw in your container screen shot you enabled the "privileged" flag. This is not necessary at all to set for the mosquitto container.

Thx
Armin
You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply
#8
Here is how to edit the configuration file in the container manually using the embedded container console in 7 steps:

1. Click the embedded console icon of the container
2. Choose "/bin/sh" as console terminal service and press connect
3. Call "vi" Linux editor plus the file to edit with "vi /mosquitto/config/mosquitto.conf"
4. Press key "i" in the opening editor to activate the editor mode to "inserting"
5. Insert the lines as first lines in the file
   "listener 1883"
    "allow_anonymous true"
6. Press key "Esc" and then ":" then "w" and then "q" which is the command "write quit".
7. Then restart the container

Here is a picture of the steps 1 to 5

   
You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply
#9
Dear Armin,

Thank you very much for your quick and kind response.
I tried 2 things according to your information.

1) I loaded eclipse-mosquitto:1.6.
2) I loaded eclipse-mosquitto:latest and modified the file 'mosquitto.conf' to add 2 lines.

Both of the above, the MQTT communication worked successfully.
I confirmed that from both of the debug view by debug node and MQTT Explorer.

I really appreciate your support!!!
Best regards,
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  MQTT test DSongra 12 7,595 October-20th-2020, 08:20 AM
Last Post: Armin@netPI
  Node-Red MQTT with SSL/TLS can't connect to broker BFH_SAM2 6 5,484 May-18th-2018, 08:48 AM
Last Post: Armin@netPI
  Receive iot hub messages through MQTT adapter marcel 1 2,525 March-15th-2018, 05:56 PM
Last Post: Armin@netPI

Forum Jump:


Users browsing this thread: 1 Guest(s)