Kind regards to the community.
I configured all the components, connected them and got them working with OH3. After a while, I notice that OH3 says: "COMMUNICATION_ERROR
CONNECT failed as CONNACK contained an error code: NOT_AUTHORIZED.
Mosquitto is running. I tested this with the MQTT Explorer tool on Windows.
Who can help me? How do I get stable communication between OH3 and Mosquitto?
First of all: where is your broker installed and how did you install and configure it?
Means: you could send and receive MQTT messages and your channels and items were updated accordingly? please be more specific, leave your broker configuration here (of course without the credentials), and describe when and how the connection breaks - otherwise we don’t have anything to help you
Yes, with the MQTT Explorer (a tool under windows) I can send and receive data. I just saw the following error message in OH3.
io.netty.channel.AbstractChannel$AnnotatedNoRouteToHostException: No route to host: /198.168.0.33:1883
I had deleted the MQTT Broker in OH3 and restarted the Raspy before. Then I created the broker again and I saw the above message
Please be more specific… We can’t help you that way. So either you don’t know what MQTT does and that’s why you see these errors, or you have a wrong configuration within OH3… in both situation we need what I asked for:
a proper description of the steps you took (including the configuration within OH3)
the errors you receive
the surrounding information on how and what you did with MQTT explorer
Hallo und guten Abend Herr Binder, vielen Dank für Ihre Antworten. Ich beschäftige mich rein privat mit dem Thema und bin Ihnen dankbar für die Freizeit die Sie hier investieren. Ich bin ein absoluter Windows Nutzer und habe mit Linux quasi keine Erfahrung.
Nun zum Thema
Ich habe das zuvor genannte Image auf meinem Raspy installiert und untere zuhilfenahme eines Tutorials von Bangertech auch zum Laufen gebracht. Ich habe Schalter eingebunden und hatte bereits eine kleine Oberfläche auf dem Handy gestaltet.
Mit einmal war die Verbindung zwischen OH3 und Mosquitto OFFLINE. Alle BemĂĽhungen es wieder zum Laufen zu bringen, sind bisher gescheitert. Es kann ja kein Programmierfehler sein, da ich keinen Code schreibe.
Mit Hilfe des MQTT Explorers auf meinem Laptop, kann ich auch auf den Mosquitto zugreifen, den Status der Schalter sehen und auch den Toggle-Befehl absetzen. Auch wenn ich die Schalter über die eigene Weboberfläche anspreche sehe ich die Reaktion im MQTT Explorer. Das heißt für mich Mosquitto läuft.
Ich habe bereits zweimal das Openhab Image neu aufgesetzt und neu begonnen. Dann bekomme ich das System auch zum Laufen. Nur nach einer Zeit X ist es wieder weg.
Noch etwas zur Installation. Ich habe zuvor genanntes Image installiert und aus dem KonfigurationsmenĂĽ heraus das Mosquitto installiert und eingestellt. Openhab und Mosquitto sind auf dem Raspberry installiert
Please remain in english, it’s the official forum language.
Second, please provide the configuration within OH3. If you can use the broker installed on the same raspberry as OH3 is installed (which works fine, nothing wrong with that…) that means, the Broker is live and running - but openHAB3 can’t use it. So, we need to make sure, this works.
And it’s ok if you’re a novice and that’s why we are here to help in the forum. But as described, we need more input… So please do the following:
then please describe what you did (I can read from your post, that you installed mosquitto from openHABian (which is crucial, because now we now, what broker you use and that you’re using the openHAB image) and then
please post your configuration of the broker within openHAB, because the error must be inside this.
and if you like, please describe, what use case you’re after, meaning why do you need MQTT and what do you want to achieve with it - helps for context.
PS: and please, I’m not mad at you - it’s just, we need some more input other than “it doesn’t work”
I have installed the OH-image and Mosquitto on the Raspy
I opened OH in my Browser (Chrome)
I installed the addon MQTT-Binding
I went in the main menue to the item MQTT system broker connection
Connection Name: MQTTBrokerJA / Broker Host: localhost / no further settings
I went to Things and press MQTT-Binding
I press MQTT-Broker
Unique ID: no settings
Label: MQTT Broker JA
Broker Hoste Name: localhost
And then I got the message: COMMUNICATION_ERROR
CONNECT failed as CONNACK contained an Error Code: NOT_AUTHORIZED.
On the Raspy I did a test
mosquitto_pub -d -t testTopic -m “Hello world!”
There I got the message
Client mosqpub|4527-openHABian sending CONNECT
Client mosqpub|4527-openHABian received CONNACK (5)
Connection Refused: not authorised.
Error: The connection was refused.
Remove that - it might not work as expected. It is something has needs removing, as it is a relic from the days that the MQTT Binding included its own broker. And it sounds like you’ve tried to setup two connections.
Instead, create a connection to your broker like this:
Presumably that’s because you didn’t provide your username and password in your command
When you set your Mosquitto broker up, did you choose a username and password? I’m not sure whether openhabian sets one by default…
Please read through the documentation I gave you above. It seems you don’t know how and why you use MQTT in the first place.
So, if you don’t know, if you configured your broker with username/password or not, it won’t make sense to go through further steps with your configuration… (…and what do you do with MQTT explorer anyways?)
Again: What’s your purpose of using MQTT in the first place?
You could compare your configuration from the MQTT Explorer with the one in the binding, if your Windows client is able to use the broker, you should simply use this configuration in openHAB.
It’s starting to get more frustrating for us, if you seem to just throw in something and don’t know yourself, what you’re doing:
My bet (don’t know, because we still lack crucial information) is, you configured mosquitto with login/password - but the configuration of your broker in OH3 misses this information. Again: please make sure, you understand at first, what you’re doing - then we can help you with specific information and we all don’t go in blindly…
Hello Thomas sorry that ist so difficult. But let me start again.
Today I’ve installed the newest version of OH3 and Mosquitto on my Raspy. I’ve installed Mosquitto with the user “openhabian” and a Passwort (2 letters and 6 numbers).
I downloaded the Addon MQTT-binding and activated Wifi.
This I did all on my Raspy.
I started the system and everything looked fine. Only I saw this line:
2021-01-28_18:00:40_CET [openHABian] Checking for default openHABian username:password combination… FAILED
Now I started the OH3 in Chrome on my notebook.
I went in the menue Settings to the item MQTT system broker connection
Connection Name: no / Broker Host: localhost / secure connection=off/ no further settings
I went back to Things and press MQTT-Binding
I press MQTT-Broker
Unique ID: MeinBroker / Label: MQTT Broker / Broker Hostname: localhost
And then I got the message: COMMUNICATION_ERROR
CONNECT failed as CONNACK contained an Error Code: NOT_AUTHORIZED.
openhabian@openhabian:~ $ mosquitto_pub -d -t testtopic -m “hello”
Client mosqpub|4907-openhabian sending CONNECT
Client mosqpub|4907-openhabian received CONNACK (5)
Connection Refused: not authorised.
Error: The connection was refused.
With my MQTT Explorer, running on my Notebook, I have no problems to connect to Mosquitto.
It doesn’t matter if I use a user/password or not.
I think that you are right with the user/password in Mosquitto. But I don’t know, where is my mistake.
This is all informations I can give you and I’ve tried to communicate it so precise as possible. If that’s not enough for you, I’ll have to take an other way.
I’m aware what it is, but I am right. You’re not supposed to use that. Configure your broker using the tutorial I posted, or if you don’t believe me, use the documentation:
That one is really strange! but I have to stop you right here:
Did you install mosquitto with sudo openhabian-config and then chosing menu 23? With that comes an setup guide, which should ask you for username/password combination?