Mqtt connection problem after upgrading to openhabian v3.1

  • Platform information:
    • Hardware: _RaspberriPi 3B
    • openHAB version: 3.1.0

Problem:
Thing Mosquitto:
COMMUNICATION_ERROR
io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: /192.168.1.110:1883

I have been using openhab 2.5 but my sdcard get corrupted so I choose to start from scratch.
Downloaded image and burned to a new sd card 16 GB.
Initialization was ok.
make binding to Mosquitto. OK
I have installed Mosquitto from openhabian-config.
it reported OK up and running in the background.

Unable to connect using MQTT.fx Saying connection refused

From PuTTY
systemctl status Mosquitto report OK.

Trying Mosquitto_sub with test message.

it works with -h localhost.
it dont work with -h 192.168.1.110

Any help to solve this is needed

This would suggest that .110 is not the IP address of your RPi. Is your IP address reserved in your router settings, or was it specified in your old SD card’s wifi config file? If the latter, you need to do that again and then reboot so that it will get assigned correctly by your router.

Personally, I prefer to do all DHCP reservations at the router, but I know that’s not possible for everyone.

Is there any additional information being logged in /var/log/mosquitto/mosquitto.log ?
What is the output of

sudo netstat -tulpn | grep 1883

The ip address is fix and comeback from the router, so this not the problem.
I have not given any username and password to the brokker.
This was not needed before. Could that be an issue?

Sudo netstat -tulp | grep 1883:
tcp 0 0 localhost:1883 0.0.0.0:* LISTEN 836/mosquitto
tcp6 0 0 localhost:1883 [::]:* LISTEN 836/mosquitto

This tell me that localhost is ok.
192.168.1.110 is the correct ip-address, so why can’t it be used?

From the mosquito.log:
1637162226: Config loaded from /etc/mosquitto/mosquitto.conf.
1637162226: Starting in local only mode. Connections will only be possible from clie>
1637162226: Create a configuration file which defines a listener to allow remote acc>
1637162226: For more details see https://mosquitto.org/documentation/authentication->
1637162226: Opening ipv4 listen socket on port 1883.
1637162226: Opening ipv6 listen socket on port 1883.
1637162226: mosquitto version 2.0.11 running
1637162226: mosquitto version 2.0.11 terminating
1637162226: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1637162230: mosquitto version 2.0.11 starting
1637162230: Config loaded from /etc/mosquitto/mosquitto.conf.
1637162230: Starting in local only mode. Connections will only be possible from clie>
1637162230: Create a configuration file which defines a listener to allow remote acc>
1637162230: For more details see https://mosquitto.org/documentation/authentication->
1637162230: Opening ipv4 listen socket on port 1883.
1637162230: Opening ipv6 listen socket on port 1883.
1637162230: mosquitto version 2.0.11 running
1637170719: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1637172520: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1637174321: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1637176121: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1637177922: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1637178575: New connection from ::1:44010 on port 1883.
1637178575: New client connected from ::1:44010 as auto-378C4E3B-4B9B-0645-2ECC-8F74>
1637178808: Client auto-378C4E3B-4B9B-0645-2ECC-8F7411ECE431 closed its connection.
1637179724: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.

1 Like

Seems important.

1 Like

I Think you’r right. That’s the problem.
I don’t know how to edit the config file and where to find it.
Could you help me?
Sorry to be a novice :disappointed:

No idea, this is about Mosquitto not openHAB.
Might help -

Hi @Gun007 - you’ll find the configuration file in /etc/mosquitto, it’s called mosquitto.conf.

In a Raspberry Pi, you’ll probably prefer nano to other built-in editors, so you’d edit it with the command below:

nano /etc/mosquitto/mosquitto.conf

Have a read of my other post that @rossko57 linked, as well as the linked info from the Mosquitto website - that should get you up and running.

1 Like

Thank you.
I have edited mosquito.conf
listener 1883
allow_anonymous true

But still I get connection refused.

Reboot didn’t help.

Is it possible to install an older version of mosquito?

openhabian should be taking care of this stuff for you.
What does your mosquitto log say now?

637230630: mosquitto version 2.0.11 starting
1637230630: Config loaded from /etc/mosquitto/mosquitto.conf.
1637230630: Starting in local only mode. Connections will only be possible from clients running on this machine.
1637230630: Create a configuration file which defines a listener to allow remote access.
1637230630: For more details see Authentication methods | Eclipse Mosquitto
1637230630: Opening ipv4 listen socket on port 1883.
1637230630: Opening ipv6 listen socket on port 1883.

Strange i’m sure that my conf has the allow_anonymous true

Here it is:

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

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

listener 1883
allow_anonymous true

Please correct the thread title. You neither upgraded nor does it have anything to do about openHABian.
(or not even openHAB so it seems). And it’s openHAB 3.1, not openHABian. Thank you.

can you post you configuration files that are located in /etc/mosquitto and /etc/mosquitto/conf.d ?

Hi
The last post has the mosquitto.conf


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

listener 1883
allow_anonymous true

Mosquitto/conf.d is empty and when I tried to save a file there I got access not permitted.

I am sorry if this is not correct.
I don’t know how to change the thread.

I have upgraded to openHAB 3.1.
This has given the mqtt problem.
I think I’m not the only person who has problem with MQTT after upgrade. It seems that some sort of configuration file has to be setup. The documentation in openHAB don’t telle who to do it and then it’s needed.
I have tried to solve this for more than a week now.

I have found great help from @Wolfgang_S and @Wolfgang_S

Hi
I tried one more time and this time I was able make a conf file in /etc/mosquito/conf.d

I have removed my entries in mosquitto.conf so it’s now has the default content

I have save a file ej_mosquitto.conf in /etc/mosquitto/conf.d/
Content:
listener 1883
allow_anonymous true

Hurrah: now mosquitto is up and running.

Problem solved. @rossko57 and @Wolfgang_S

2 Likes

use the pencil next to the the title

The solution that worked for me:

Fresh openhabian install on Rpi4. Installed mosquitto via the openhab-config. Mosquitto cleints failed to connect until I found this fix. Thanks.

It used to install problem and hassle free. This new issue wasted my weekend.


sudo systemctl stop mosquitto.service
sudo nano /etc/mosquitto/mosquitto.conf

Add:

listener 1883 0.0.0.0
allow_anonymous true
sudo systemctl start mosquitto.service