MQTT configuration error - what is my broker, username, password?

I am using Windows 7 and installed mosquitto.
How do I know I am entering the correct broker address and port? Where can I find these values? Do I need to set a username and password, or can I leave these fields out of my configuration.yaml?
Running ipconfig on windows command line gives me:
ipv4 address: 10.0.0.235
default gateway: 10.0.0.1
Both of these values result in “invalid config” errors for mqtt. Please help, thanks.

Hi,

your broker adress should be 10.0.0.235.

Username and Password are not set per default (so far i know)

You can set it via commandline and mosquitto_passwd command.

You should have a look at the mqtt component for configuring to HA

For example Username and Password are marked as optional.

Here is a guide for installing mosquitto on Windows, maybe it helps you to check if services is running and so on.

BR

Lukas

Thank you for your response, Lukas.
I had followed the steps in sivatechworld.com originally, but I think I forgot step 9 – reinstall mosquitto after downloading the dlls in the correct directory.

After reinstalling, and running netstat -an:
Active Connections
TCP 10.0.0.235:139 0.0.0.0:0 LISTENING

I updated my port value in my configuration.yaml, and now the invalid config error is gone.
mqqt:
broker: 10.0.0.235
port: 139
client-id: home-assistant-1
keepalive_ 60
protocol: 3.1.1

Thanks again for the help.

Glad to here i could help you out

@outrun @lukeremy i installed Mosquitto broker on windows 10 can you access your broker outside local network?

I’m using cloudmqtt and owntracks but cloudmqtt is limited to 10 connections can I use mosquitto and owntracks?

@Ashfaaa

Yes you can use it, but you have to set a Portforward on your Router for your Mosquitto Broker.

For this, i would strongly recommend a least a username and password authentication for your broker.
If your ISP also change your IP frequent, just have a look at some DynDNS-Services.

how can i set a username and password for mosquitto broker… for ip i can set a dhcp reservation on router it should work right?

@Ashfaaa the IP is your external IP, you can check this ip on http://www.whatsmyip.org/ My Provider change it not very often so I using a Domain with a static record. If your Provider change this IP on a daily base, i would recommend https://www.duckdns.org/

Username and password for mosquitto can be set via

or have a look here

http://www.steves-internet-guide.com/mqtt-username-password-example/

Be carefull, if you add a username and a password you will have to reconfigure all devices using your local broker.

Br

Lukas

i’m using duckdns.org to access my HA outside my local network it works fine so can I skip this step or do I need to set it separately for Mosquitto broker?.. sorry I’m kinda new for all this :slight_smile:

He,

OK fine, so can skip this step. Your Broker URL is then your duckdns.org name.

No problem, it was just the same for me, some time ago :slight_smile:

thank you so much for your help…one more doubt my link goes like this http://xxxx.duckdns.org/8123 with a simple login password for HA… hope it will still work without HTTPS://

Yes it will work without https:// since you don’t setup a certificate. HTTPS is adding a additonal security layer to your Setup with encrypting your traffic. If you want https:// encryption you have to set it up for HA and for MQTT seperatly.

I have created a file how that link explained and changes this 2 in mosquitto.conf file

(#password_file c:\Program Files (x86)\mosquitto\passwordfile.txt)
(#allow_anonymous false)

but still when I tried in android MQTT dashboard app to connect http://xxxduckdns.org:8123 port:1883 username xxx password zzz

but it does not connect to it. I’m doing something wrong?

you should use http://xxduchdns.org without :8123

:8123 is for accesing HA
:1883 is for the mqtt broker

tried it works. but even if leave username and password empty i can access the broker.

Hmm, than there is something wrong with your conf File i guess. Did you reload the service after the changes?

yes i stop it under services and started it back…

and are you using HA and Mosquitto on Windows?

#Edit

I didn’t know that I had to remove the # from the beginning of the line I removed the line and it works now thank you.

Good Morning @Ashfaaa (at least in Austria :slight_smile: )

Glad to here its working.

BR

Lukas

Good Morning @outrun from Saudi Ariabia

all thanks to you lukas without your help i would have not done this…

and are you using HA on windows? and when im on local network host have to be 192.168.x.xxx i can not use ducdns host on local network is there any fix for this?

Hi, i switched over to a PI about 3 or 4 month ago, because it fits my usecase better.

But if you like to use the DuckDns-Adresse also internal from your PC, Phone, Tablet,… then it depends on your Router, if your Router can emulate a DNS-Domain. At least on your PC you can user your DuckDNS-Adress with editing your Host-File.

The hosts-File is located at %windir%\System32\drivers\etc and is named hosts (without extension).

You have to open it with an administrative editor.

Than you can add a line:

192.168.x.x yourduckdnsdomain.com

and save it.

With this entry you say that your Windows system resolves the duckdnsdomain to your local IP.

Be carefull with this entry your PC is not able to resolve your duckdnsdomain correctly if you use it outside your network (likely if your pc is a notebook and you try it from mcdonalds :slight_smile: )

If you use the hosts-files method, it will not affect your other network-devices.
This you can only achieve with a DNS-Server-Config. Maybe you can tell us, what router model you have, so we can check it out.

1 Like