# Mqtt in node always says connecting

**URL:** <https://discourse.nodered.org/t/mqtt-in-node-always-says-connecting/86466>\
**Category:** General\
**Tags:** mqtt\
**Created:** [15 March 2024 18:21 UTC](https://discourse.nodered.org/t/mqtt-in-node-always-says-connecting/86466 "2024-03-15T18:21:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniel90](https://avatars.discourse-cdn.com/v4/letter/d/c4cdca/32.png) [@daniel90](https://discourse.nodered.org/u/daniel90)\
**Post date:** [15 March 2024 18:21 UTC](https://discourse.nodered.org/t/mqtt-in-node-always-says-connecting/86466/1 "2024-03-15T18:21:14Z")

</div>

hello everyone,  
i really struggling with this problem, my mqtt in node wont connected to my public broker, while i really sure that i configure the setting of my mqtt connection to broker was all right

note: the picture below that says disconnected is actually not represent my latest problem that i encounter that my node says 'connecting'

 ![IMG-20240316-WA0001](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/5/95f8e1ac8a83cfcb0ce27a6d17de336c4607a479.jpeg)  
 ![FB_IMG_1710526852374](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/d/ad84a9af5c39b65ed58adcc80f6d0ff70a6a67d6.jpeg)

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [15 March 2024 18:52 UTC](https://discourse.nodered.org/t/mqtt-in-node-always-says-connecting/86466/2 "2024-03-15T18:52:12Z")

</div>

Here's a very simple Node-RED flow for a MQTT test using a FREE broker.  
This should test if your setup is working.

![quick_mqtt_test](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/2/72bfc90df99ee3323d96d4feaa2ad7a771e23001.png)  
If you click the 'Inject' node you should see this message arrive in the 'Debug' node.

![mqtt_debug](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/8/68ca1b6adf7b0e252da281c95834814a2174c9cb.png)

As a starting point, import the Node-RED flow below and make sure it works for you.

```auto
[{"id":"447794de5aa4fb6c","type":"tab","label":"Quick MQTT test","disabled":false,"info":"","env":[]},{"id":"219d4b3ff09c4bbf","type":"mqtt in","z":"447794de5aa4fb6c","name":"","topic":"myquicktest","qos":"2","datatype":"auto-detect","broker":"190876ba43bba92a","nl":false,"rap":true,"rh":0,"inputs":0,"x":190,"y":160,"wires":[["e5746f22a5f06a14"]]},{"id":"0ec31304e605cff4","type":"mqtt out","z":"447794de5aa4fb6c","name":"","topic":"myquicktest","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"190876ba43bba92a","x":390,"y":100,"wires":[]},{"id":"a01f3b5a0d9755f4","type":"inject","z":"447794de5aa4fb6c","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Hello World","payloadType":"str","x":190,"y":100,"wires":[["0ec31304e605cff4"]]},{"id":"e5746f22a5f06a14","type":"debug","z":"447794de5aa4fb6c","name":"MQTT_In_debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":410,"y":160,"wires":[]},{"id":"366114aeee0a573f","type":"comment","z":"447794de5aa4fb6c","name":"A quick test using a mosquitto.org FREE remote broker","info":"","x":300,"y":40,"wires":[]},{"id":"190876ba43bba92a","type":"mqtt-broker","name":"","broker":"test.mosquitto.org","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"autoUnsubscribe":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willRetain":"false","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]

```

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [15 March 2024 19:03 UTC](https://discourse.nodered.org/t/mqtt-in-node-always-says-connecting/86466/3 "2024-03-15T19:03:41Z")

</div>

You have given us next to nothing to go on @daniel90.

However, the gibberish in your Server field looks similar to my setup for HiveMQ.  
You need this info from [hivemq.com](http://hivemq.com)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/d/5d1aa26ce3762367f632292017d04411a9cdf68a.png)

And access credentials from

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/b/1b4dba383a517ed8bab06679d7fb1575819f656e.png)

Then in Node-red

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/a/ba0de3a724a7bdbdc85ccbb4f0bdd4d30d8b5287.png)

Finally

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/2/b250ad210224f3e3bbe1c0f287c92603a4d1f2a4.png)

---

<div class="post-metadata">

**Author:** ![daniel90](https://avatars.discourse-cdn.com/v4/letter/d/c4cdca/32.png) [@daniel90](https://discourse.nodered.org/u/daniel90)\
**Post date:** [16 March 2024 08:17 UTC](https://discourse.nodered.org/t/mqtt-in-node-always-says-connecting/86466/4 "2024-03-16T08:17:05Z")

</div>

i already to that accordingly sir, but the result is same always connecting

 ![WhatsApp Image 2024-03-16 at 15.15.22](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/f/ff3014f23bec37934a60094bf1d12d27486d2bbe.jpeg)  
 ![WhatsApp Image 2024-03-16 at 15.15.57](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/5/2592960b7690a8d9063b9070477ef4f45525e2f8.jpeg)

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [16 March 2024 08:32 UTC](https://discourse.nodered.org/t/mqtt-in-node-always-says-connecting/86466/5 "2024-03-16T08:32:49Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/a/ead3724f026261842e68205c9e2691627b493217.png)

Well it works for me. Sorry about that.

Note that it only works if I have Use TLS ticked, as you see in my screen capture. But my TLS configuration has nothing except a tick against Verify server certificate.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [17 March 2024 08:42 UTC](https://discourse.nodered.org/t/mqtt-in-node-always-says-connecting/86466/6 "2024-03-17T08:42:52Z")

</div>

As well as not having TLS ticked in 1st screenshot, you also have MQTT 3.1 legacy selected - change that to MQTT 3.1.1

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [15 June 2024 08:43 UTC](https://discourse.nodered.org/t/mqtt-in-node-always-says-connecting/86466/7 "2024-06-15T08:43:27Z")

</div>

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