# MQTT broker- client connection

**URL:** <https://discourse.nodered.org/t/mqtt-broker-client-connection/86742>\
**Category:** General\
**Created:** [25 March 2024 12:33 UTC](https://discourse.nodered.org/t/mqtt-broker-client-connection/86742 "2024-03-25T12:33:28Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![colin0031](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin0031/32/85027_2.png) [@colin0031](https://discourse.nodered.org/u/colin0031)\
**Post date:** [25 March 2024 12:33 UTC](https://discourse.nodered.org/t/mqtt-broker-client-connection/86742/1 "2024-03-25T12:33:28Z")

</div>

Hello,

Hope everyone having a great day. I'm working on an exiting project to collect data from a robot and I do experience some difficulties. Let me know your suggestions;

The robot as a client is supposed to send out data in mqtt to a broker(Node-red-aedes) which is on a windows based pc.(Both robot and pc isn't connected to internet).

And my pc has 4 network carts as shown in picture below. How can I make sure that the my aedes-node-red broker only uses 192.168.3.253??? Its only possible to configure port inside broker.

 ![nodered architecture](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/1/013514714702e23fad5ec49e97e4f7685f59d9e5.jpeg)

Also any recommendations for other broker which can be installed on a windows based machine?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [25 March 2024 12:47 UTC](https://discourse.nodered.org/t/mqtt-broker-client-connection/86742/2 "2024-03-25T12:47:03Z")

</div>

Hi, if you forgo Node-red-aedes and install mosquitto (as a service) you will have a much better solution. Additionally, Mosquitto can be configured to bind to the ethernet IP address as you require.

Better still, this will remove a bottleneck from Node-RED and be more resilient (since Node-RED restarts and deploys will not cause the broker to drop offline)

---

<div class="post-metadata">

**Author:** ![colin0031](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin0031/32/85027_2.png) [@colin0031](https://discourse.nodered.org/u/colin0031)\
**Post date:** [25 March 2024 14:30 UTC](https://discourse.nodered.org/t/mqtt-broker-client-connection/86742/3 "2024-03-25T14:30:36Z")

</div>

Thanks a lot @Steve-Mcl . And to manipulate the IP address I think i need to go to mosquitto.conf.. isnt it?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [25 March 2024 14:36 UTC](https://discourse.nodered.org/t/mqtt-broker-client-connection/86742/4 "2024-03-25T14:36:26Z")

</div>

yes

To bind Mosquitto to a specific IP address you need to modify the Mosquitto configuration file (usually named `mosquitto.conf`).

1. Open the Mosquitto configuration file in a text editor. The default location is `C:\ProgramData\Mosquitto`)
2. Add `listener 1883 <ip-address>` where `<ip-address>` is the IP you want to bind to

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [25 March 2024 15:01 UTC](https://discourse.nodered.org/t/mqtt-broker-client-connection/86742/5 "2024-03-25T15:01:31Z")

</div>

Note though that the actual IP address you use to connect to mosquitto must be the IP address of the device running mosquitto.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [25 March 2024 17:15 UTC](https://discourse.nodered.org/t/mqtt-broker-client-connection/86742/6 "2024-03-25T17:15:49Z")

</div>

Also, don't forget to add an entry to Windows Firewall to allow port 1883 inbound access.

And note that the connection as discussed here is NOT SECURED at all. May not matter to you but you should be aware.

---

<div class="post-metadata">

**Author:** ![colin0031](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin0031/32/85027_2.png) [@colin0031](https://discourse.nodered.org/u/colin0031)\
**Post date:** [26 March 2024 12:43 UTC](https://discourse.nodered.org/t/mqtt-broker-client-connection/86742/7 "2024-03-26T12:43:04Z")

</div>

Good afternoon Gents,

Scenario- Mosquitto running as a service and node-red-mqtt node as a client on same pc.

Situation1-Node is getting connected when server is configured as "localhost".  
Situation 2-Node gets disconnected when I write IP address of computer on Server config.

However instead of Mosquitto as a service, when I use nodered-Aedes broker, both above situations works.  
At the moment no inbound rules created on windows firewall- I suspect it as the cause.

How to find the IP which is used by Mosquitto(service on windows???

When using aedes broker- all client infos are available in debug window of nodered. Is it possible to get a log or similar info from mosquitto broker(which runs as a service)???

Thanks for any input.

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [26 March 2024 17:35 UTC](https://discourse.nodered.org/t/mqtt-broker-client-connection/86742/8 "2024-03-26T17:35:51Z")

</div>

> [@colin0031](#):
>
> How to find the IP which is used by Mosquitto(service on windows???

It should be the IP you setup here -

> [@Steve-Mcl](#):
>
> - Open the Mosquitto configuration file in a text editor. The default location is `C:\ProgramData\Mosquitto`)
> - Add `listener 1883 <ip-address>` where `<ip-address>` is the IP you want to bind to

By default Mosquitto only allows local connections, so if you haven't setup the listener then it will not allow a connection from another IP. Also it will only allow unauthenticated access via localhost, so you need to setup authentication, or explicitly allow anonymous connections.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [26 March 2024 17:37 UTC](https://discourse.nodered.org/t/mqtt-broker-client-connection/86742/9 "2024-03-26T17:37:22Z")

</div>

> [@colin0031](#):
>
> Situation1-Node is getting connected when server is configured as "localhost".  
> Situation 2-Node gets disconnected when I write IP address of computer on Server config.
> 
> However instead of Mosquitto as a service, when I use nodered-Aedes broker, both above situations works.

If you use the IP address, you are forcing the traffic to leave the PC, go via your switch or router and then come back in, just like traffic from a different device would come in.

Using localhost or 127.0.0.1 keeps the traffic within the device and so it doesn't hit the Windows firewall and so works.

Use mosquitto and set up the inbound firewall rule.

---

<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:** [24 June 2024 17:37 UTC](https://discourse.nodered.org/t/mqtt-broker-client-connection/86742/10 "2024-06-24T17:37:34Z")

</div>

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