Can't get MQTT to work.

Others (MiLight, Hue, Toon etc...)

Moderator: leecollings

Post Reply
PeJeWe
Posts: 56
Joined: Monday 28 November 2016 20:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Latest
Location: Netherlands
Contact:

Can't get MQTT to work.

Post by PeJeWe »

I'm starting with MQTT and want to use it with esp8266 devices :oops:
i can't get it to work.
what's working now:
i can send local messages to domoticz (mosquitto_pub -h localhost -m '{ "idx" : 1, "nvalue" : 0, "svalue" : "25.0" }' -t 'domoticz/in')
I can''t get it to work from outside the localhost (domoticz RPI3b+)
my mosquitto config file looks like this:

Code: Select all

# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example

per_listener_settings true

pid_file /run/mosquitto/mosquitto.pid

persistence true
persistence_location /var/lib/mosquitto/

log_dest file /var/log/mosquitto/mosquitto.log

include_dir /etc/mosquitto/conf.d
allow_anonymous false
listener 1883
password_file /etc/mosquitto/passwd

and is located at /etc/mosquitto/mosquitto.conf
i use the firewall ufw and have set the port 1883 open for traffic ipv4 and ipv6 (with the firewall disabled it is not working either)
when i want to connect to my broker from a windows pc with MQTT explorer it keeps disconnecting.

I have set a mqtt username with password.
anonymouse or with user/password login it won't let me login externally.
i use a normal IP range like (192.168.1.1 to 192.168.1.254)

Has anyone of you guys tips/tricks?
hoeby
Posts: 528
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: Can't get MQTT to work.

Post by hoeby »

What is in the log file?
Maybe there is more info, what the problem is

Code: Select all

var/log/mosquitto/mosquitto.log
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
PeJeWe
Posts: 56
Joined: Monday 28 November 2016 20:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Latest
Location: Netherlands
Contact:

Re: Can't get MQTT to work.

Post by PeJeWe »

hoeby wrote: Thursday 19 October 2023 23:04 What is in the log file?
Maybe there is more info, what the problem is

Code: Select all

var/log/mosquitto/mosquitto.log

Code: Select all

1697666632: 
1697726065: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1697726489: New connection from 192.168.2.3:50382 on port 1883.
1697726489: Client <unknown> disconnected due to protocol error.
1697726490: New connection from 192.168.2.3:50383 on port 1883.
1697726490: Client <unknown> disconnected due to protocol error.
1697727866: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1697740089: Client Domoticz115a1f42-fe1d-4f72-8ba7-a0f0******** closed its connection.
1697740090: New connection from ::1:36514 on port 1883.
1697740090: Client <unknown> disconnected, not authorised.
1697740097: New connection from ::1:50332 on port 1883.
1697740097: Client <unknown> disconnected, not authorised.
1697740119: New connection from ::1:32770 on port 1883.
1697740119: Client <unknown> disconnected, not authorised.
1697740126: New connection from ::1:48188 on port 1883.
1697740126: Client <unknown> disconnected, not authorised.
1697740473: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1697740474: New connection from ::1:44930 on port 1883.
1697740475: Client <unknown> disconnected, not authorised.
1697740493: New connection from ::1:32956 on port 1883.
1697740493: Client <unknown> disconnected, not authorised.
1697740504: New connection from ::1:47788 on port 1883.
1697740505: Client <unknown> disconnected, not authorised.
1697740523: New connection from ::1:43516 on port 1883.
1697740643: Client <unknown> disconnected, not authorised.
1697740647: mosquitto version 2.0.11 terminating
1697740647: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1697740647: mosquitto version 2.0.11 starting
1697740647: Config loaded from /etc/mosquitto/mosquitto.conf.
1697740647: Opening ipv4 listen socket on port 1883.
1697740647: Opening ipv6 listen socket on port 1883.
1697740647: mosquitto version 2.0.11 running
1697740655: New connection from ::1:60588 on port 1883.
1697740655: New client connected from ::1:60588 as Domoticz3ee639ba-2d9c-466f-844b-94a99********* (p2, c1, k120, u'domoticz').
1697740673: New connection from ::1:41664 on port 1883.
1697740723: mosquitto version 2.0.11 terminating
1697740723: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1697740723: mosquitto version 2.0.11 starting
1697740723: Config loaded from /etc/mosquitto/mosquitto.conf.
1697740723: Opening ipv4 listen socket on port 1883.
1697740723: Opening ipv6 listen socket on port 1883.
1697740723: mosquitto version 2.0.11 running
1697740747: New connection from ::1:34456 on port 1883.
1697740747: New client connected from ::1:34456 as Domoticz3ee639ba-2d9c-466f-844b-94a998********* (p2, c1, k120, u'domoticz').
1697740747: New connection from ::1:34464 on port 1883.
1697740748: New client connected from ::1:34464 as Domoticz-MQTT-AutoDiscover63535b57-82ea-49d3-ad47-50f05e********* (p2, c1, k120, u'domoticz').
1697740912: New connection from 192.168.2.3:50290 on port 1883.
1697740912: Client <unknown> disconnected due to protocol error.
1697740913: New connection from 192.168.2.3:50291 on port 1883.
1697740913: Client <unknown> disconnected due to protocol error.
1697740914: New connection from 192.168.2.3:50292 on port 1883.
1697740914: Client <unknown> disconnected due to protocol error.
1697740915: New connection from 192.168.2.3:50293 on port 1883.
1697740915: Client <unknown> disconnected due to protocol error.
1697741024: Client Domoticz-MQTT-AutoDiscover63535b57-82ea-49d3-ad47-50f05********* closed its connection.
1697741272: mosquitto version 2.0.11 terminating
1697741272: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1697741272: mosquitto version 2.0.11 starting
1697741272: Config loaded from /etc/mosquitto/mosquitto.conf.
1697741272: Error creating listener: Name or service not known.
1697741272: mosquitto version 2.0.11 starting
1697741272: Config loaded from /etc/mosquitto/mosquitto.conf.
1697741272: Error creating listener: Name or service not known.
1697741272: mosquitto version 2.0.11 starting
1697741272: Config loaded from /etc/mosquitto/mosquitto.conf.
1697741272: Error creating listener: Name or service not known.
1697741273: mosquitto version 2.0.11 starting
1697741273: Config loaded from /etc/mosquitto/mosquitto.conf.
1697741273: Error creating listener: Name or service not known.
1697741273: mosquitto version 2.0.11 starting
1697741273: Config loaded from /etc/mosquitto/mosquitto.conf.
1697741273: Error creating listener: Name or service not known.
1697741302: mosquitto version 2.0.11 starting
1697741302: Config loaded from /etc/mosquitto/mosquitto.conf.
1697741302: Opening ipv4 listen socket on port 1883.
1697741302: Opening ipv6 listen socket on port 1883.
1697741302: mosquitto version 2.0.11 running
1697741313: New connection from ::1:54242 on port 1883.
1697741313: New client connected from ::1:54242 as Domoticz3ee639ba-2d9c-466f-844b-94a99********* (p2, c1, k120, u'domoticz').
1697741866: New connection from 192.168.2.3:50541 on port 1883.
1697741866: Client <unknown> disconnected due to protocol error.
1697742328: Client <unknown> disconnected due to protocol error.
1697743102: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1697744228: New connection from 192.168.2.3:50705 on port 1883.
1697744228: Client <unknown> disconnected due to protocol error.
1697744229: New connection from 192.168.2.3:50706 on port 1883.
1697744229: Client <unknown> disconnected due to protocol error.
1697744230: New connection from 192.168.2.3:50707 on port 1883.
1697744230: Client <unknown> disconnected due to protocol error.
1697744231: New connection from 192.168.2.3:50708 on port 1883.
1697744231: Client <unknown> disconnected due to protocol error.
1697744232: New connection from 192.168.2.3:50709 on port 1883.
1697744232: Client <unknown> disconnected due to protocol error.
1697744233: New connection from 192.168.2.3:50710 on port 1883.
1697744233: Client <unknown> disconnected due to protocol error.
1697744234: New connection from 192.168.2.3:50711 on port 1883.
1697744234: Client <unknown> disconnected due to protocol error.
1697744235: New connection from 192.168.2.3:50712 on port 1883.
1697744235: Client <unknown> disconnected due to protocol error.
1697744236: New connection from 192.168.2.3:50713 on port 1883.
1697744236: Client <unknown> disconnected due to protocol error.
1697744237: New connection from 192.168.2.3:50714 on port 1883.
1697744237: Client <unknown> disconnected due to protocol error.
1697744238: New connection from 192.168.2.3:50715 on port 1883.
1697744238: Client <unknown> disconnected due to protocol error.
1697744239: New connection from 192.168.2.3:50716 on port 1883.
1697744239: Client <unknown> disconnected due to protocol error.
1697744240: New connection from 192.168.2.3:50717 on port 1883.
1697744240: Client <unknown> disconnected due to protocol error.
1697744241: New connection from 192.168.2.3:50718 on port 1883.
1697744241: Client <unknown> disconnected due to protocol error.
1697744288: New connection from 192.168.2.3:50725 on port 1883.
1697744288: Client <unknown> disconnected due to protocol error.
1697744289: New connection from 192.168.2.3:50726 on port 1883.
1697744289: Client <unknown> disconnected due to protocol error.
1697744366: New connection from 192.168.2.3:50732 on port 1883.
1697744366: Client <unknown> disconnected due to protocol error.
1697744367: New connection from 192.168.2.3:50733 on port 1883.
1697744367: Client <unknown> disconnected due to protocol error.
1697744368: New connection from 192.168.2.3:50734 on port 1883.
1697744368: Client <unknown> disconnected due to protocol error.
1697744369: New connection from 192.168.2.3:50735 on port 1883.
1697744369: Client <unknown> disconnected due to protocol error.
1697744633: New connection from 192.168.2.3:50751 on port 1883.
1697744633: Client <unknown> disconnected due to protocol error.
1697744634: New connection from 192.168.2.3:50752 on port 1883.
1697744634: Client <unknown> disconnected due to protocol error.
1697744635: New connection from 192.168.2.3:50754 on port 1883.
1697744635: Client <unknown> disconnected due to protocol error.
1697744656: New connection from 192.168.2.3:50755 on port 1883.
1697744656: Client <unknown> disconnected due to protocol error.
1697744657: New connection from 192.168.2.3:50756 on port 1883.
1697744657: Client <unknown> disconnected due to protocol error.
1697744903: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1697746704: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1697748505: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1697750306: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1697752107: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1697753908: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1697755709: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1697757510: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1697759311: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1697761112: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1697762913: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1697764714: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1697766515: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1697768316: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1697770117: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1697771918: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1697773719: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1697775520: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1697777321: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1697779122: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1697780923: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
maybe we can find the problem there
Kedi
Posts: 536
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: Can't get MQTT to work.

Post by Kedi »

Did you try without the user/password setup?
Try with log_type all or log_type_debug in the mosquitto config file.
Is there a config file in /etc/mosquitto/conf.d directory that could prevent anything?
Logic will get you from A to B. Imagination will take you everywhere.
PeJeWe
Posts: 56
Joined: Monday 28 November 2016 20:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Latest
Location: Netherlands
Contact:

Re: Can't get MQTT to work.

Post by PeJeWe »

Kedi wrote: Friday 20 October 2023 10:20 Did you try without the user/password setup?
Try with log_type all or log_type_debug in the mosquitto config file.
Is there a config file in /etc/mosquitto/conf.d directory that could prevent anything?
Q. Did you try without the user/password setup?
A. Yes i have.

Q. Is there a config file in /etc/mosquitto/conf.d directory that could prevent anything?
A.the /etc/mosquitto/conf.d directory has no files in it.
PeJeWe
Posts: 56
Joined: Monday 28 November 2016 20:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Latest
Location: Netherlands
Contact:

Re: Can't get MQTT to work.

Post by PeJeWe »

After a complete reinstall of domoticz and its components and mosquito.
I have not found te reason where it went wrong what was blocking the network connections. :roll:
I now have it running :) , and also I can connect mqtt explorer.
Only without tls.
Now I have to work it out how I can simple send data to/from domoticz.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests