Trying to use MQTT node for first time, won't connect. Just stuck on connecting w/ yellow square icon

Hi there, I'm pretty new to NR so this is probably something very obvious/easy.

I'm running an mqtt instance on my local network, but I can't seem to connect to it from NR. This instance definitely works - I can pub/sub to it from the command-line of my main workstation and it's currently supporting a number of Zigbee-based wireless devices through Home Assistant.

This is what I have done:

  1. Verified that I can publish and subscribe to the mqtt instance from a separate computer on my network, using the IP, port, and authorization credentials that I established, along with the topic.
  2. Dragged the inject (timestamp) and mqtt nodes into the workspace, and connected them together. (Basically attempting to follow this video: MQTT Publish and Subscribe Using Node Red - YouTube)
  3. Double-clicked the mqtt node and attempted to set up the server info.
  4. Under the connection tab, I have added the IP address and confirmed that the default port is correct. I have tried both the v3 and v3-legacy protocols.
  5. Under the security tab, I have entered the username and password that I am using successfully from the command-line.
    5a. Note: I have also tried connecting anonymously, after configuring mqtt to allow anonymous connections and re-verifying that I could pub/sub from my workstation without supplying credentials.
  6. I've hit the deploy button after making any/all of these changes.

Result:

  1. First, the mqtt node has a red-square icon + disconnected message right below the node.
  2. After ~10s, this changes to "connecting" with a yellow-square icon, and that's how it remains.

Other:

I'm running NR from a docker container, and I have accessed the shell for this container but I do not know any methods to troubleshoot within this environment. There appears to be some commands available like mqtt_pub and mqtt_sub, but there are no docs about how to use them. In case it's useful info, I'll also add that mqtt is running on the same physical host as NR, in a separate docker container.

Thanks in advance for any ideas/suggestions.

This may well be a docker problem, perhaps the container is not setup correctly to allow access out to the broker.

Those are part of the Mosquitto package (mosquitto-clients in fact). mosquitto_sub man page | Eclipse Mosquitto
You could test that running in a terminal inside and outside the node-red container to prove whether that is the problem.
Do you need to use node-red in Docker? I advise against it unless you have a good reason to do it.

Thanks @Colin! You confirmed my suspicions that it might be an issue with container-to-container communications, which turned out to be absolutely spot-on.

My NR container was assigned to docker's bridge network, and that was apparently the problem. I reset/rebuilt it so that it was able to use the host network, and then after re-trying the steps above I was instantly connected to the mqtt instance.

Thanks very much!

1 Like

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