-1

Good, I have installed node-red and mosquitto in docker desktop, but when I try to connect with mosquitto in node-red with mqtt it stays all the time connecting and does not change in connected.

Having mosquitto installed in docker at first I could not connect to a client as mqtt.fx, but I added some settings and I let me, but when using the node 'in' in node-red does not connect and stays that way.

The node in

The connection configuration

The configuration of the connection in the mqttfx client

What I want to achieve is to be able to connect the node 'in' of mqtt to the mosquitto broker.

hardillb
  • 54,545
  • 11
  • 67
  • 105
Juan
  • 1
  • 1

1 Answers1

0

When applications run in a container it is important to know that each container gets it's own TCP/IP stack.

This means that 127.0.0.1/localhost always points to the container the code is running in (so different for each container)

You have 2 containers, Node-RED and mosquitto, when you use 127.0.0.1 in the Node-RED container it is pointing to it's self, not something shared between both.

It works from MQTTFX because it is running on the host machine and docker has mapped the ports from the container to the host machine's TCP/IP stack.

To make this work you will need to know the IP address assigned to either the mosquitto container or the IP address assigned to the docker interface on the host machine. Or if you are using docker-compose you can use the service name of the mosquitto container.

hardillb
  • 54,545
  • 11
  • 67
  • 105