Openhab mqtt polling every 10 seconds - why?

  • Platform information:
    • Hardware: Raspberry Pi 4
    • OS: Buster
    • Java Runtime Environment: which java platform is used and what version
    • openHAB version: 2.4.0

Learning openhab on a couple of Raspberry PI’s.
Have a local PI4 running the server, and a Mosquitto broker, and have a PI Zero W running paho.mqtt.

It working well with a very basic test sitemap.

One thing I’m struggling to understand is a regular (once every 10 seconds) access to the broken from localhost. I’m assuming this is openhab polling the broker, but I’m not sure.

How can I check?

Here’s the openhab events log

2019-10-01 22:20:15.806 [hingStatusInfoChangedEvent] - 'mqtt:broker:aaf0fd34' changed from OFFLINE (COMMUNICATION_ERROR): Not authorized to connect to OFFLINE 2019-10-01 22:20:15.838 [hingStatusInfoChangedEvent] - 'mqtt:broker:aaf0fd34' changed from OFFLINE to OFFLINE (COMMUNICATION_ERROR): Not authorized to connect 2019-10-01 22:20:25.822 [hingStatusInfoChangedEvent] - 'mqtt:broker:aaf0fd34' changed from OFFLINE (COMMUNICATION_ERROR): Not authorized to connect to OFFLINE 2019-10-01 22:20:25.865 [hingStatusInfoChangedEvent] - 'mqtt:broker:aaf0fd34' changed from OFFLINE to OFFLINE (COMMUNICATION_ERROR): Not authorized to connect 2019-10-01 22:20:32.204 [ome.event.ItemCommandEvent] - Item 'Gates' received command ON 2019-10-01 22:20:32.217 [vent.ItemStateChangedEvent] - Gates changed from OFF to ON 2019-10-01 22:20:32.227 [vent.ItemStateChangedEvent] - Alarm_Status changed from GATES,OFF to GATES,ON 2019-10-01 22:20:32.239 [vent.ItemStateChangedEvent] - Alarm_Status changed from GATES,ON to GATES ARE ON 2019-10-01 22:20:35.839 [hingStatusInfoChangedEvent] - 'mqtt:broker:aaf0fd34' changed from OFFLINE (COMMUNICATION_ERROR): Not authorized to connect to OFFLINE 2019-10-01 22:20:35.871 [hingStatusInfoChangedEvent] - 'mqtt:broker:aaf0fd34' changed from OFFLINE to OFFLINE (COMMUNICATION_ERROR): Not authorized to connect 2019-10-01 22:20:43.759 [ome.event.ItemCommandEvent] - Item 'Red_Led' received command ON 2019-10-01 22:20:43.767 [vent.ItemStateChangedEvent] - Red_Led changed from OFF to ON 2019-10-01 22:20:43.775 [vent.ItemStateChangedEvent] - Alarm_Status changed from GATES ARE ON to RED,ON 2019-10-01 22:20:43.792 [vent.ItemStateChangedEvent] - Alarm_Status changed from RED,ON to RED LED ON 2019-10-01 22:20:45.872 [hingStatusInfoChangedEvent] - 'mqtt:broker:aaf0fd34' changed from OFFLINE (COMMUNICATION_ERROR): Not authorized to connect to OFFLINE 2019-10-01 22:20:45.908 [hingStatusInfoChangedEvent] - 'mqtt:broker:aaf0fd34' changed from OFFLINE to OFFLINE (COMMUNICATION_ERROR): Not authorized to connect

and a mosquitto log

1569966332: Socket error on client , disconnecting.
1569966332: New connection from 127.0.0.1 on port 1883.
1569966332: Socket error on client , disconnecting.
1569966342: New connection from 127.0.0.1 on port 1883.
1569966342: Socket error on client , disconnecting.
1569966342: New connection from 127.0.0.1 on port 1883.
1569966342: Socket error on client , disconnecting.
1569966352: New connection from 127.0.0.1 on port 1883.
1569966352: Socket error on client , disconnecting.
1569966352: New connection from 127.0.0.1 on port 1883.
1569966352: Socket error on client , disconnecting.
1569966362: New connection from 127.0.0.1 on port 1883.

Now, if I stop the openhab service, I no longer see the mosquitto connects in the log, so it does appear that it’s openhab that’s polling the mqtt broker. I guess it’s failing to connect due to incorrect user/password.

[22:46:07] openhabian@openhab:~$ sudo systemctl stop openhab2.service [22:50:34] openhabian@openhab:~$ [22:50:34] openhabian@openhab:~$ [22:50:34] openhabian@openhab:~$ sudo tail -f /var/log/mosquitto/mosquitto.log 1569966603: Socket error on client , disconnecting. 1569966613: New connection from 127.0.0.1 on port 1883. 1569966613: Socket error on client , disconnecting. 1569966613: New connection from 127.0.0.1 on port 1883. 1569966613: Socket error on client , disconnecting. 1569966623: New connection from 127.0.0.1 on port 1883. 1569966623: Socket error on client , disconnecting. 1569966623: New connection from 127.0.0.1 on port 1883. 1569966623: Socket error on client , disconnecting. 1569966633: Client paho40808483845 disconnected.

It’s telling you exactly what’s going on. COMMUNICATION_ERROR, Not authorized to connect.

OH can’t successfully connect to the broker so it keeps trying.

Please How to use code fences for logs and code.

The error is telling you that you’ve missconfigured the MQTT Broker Thing. Mosquitto doesn’t think it’s allowed to connect. Did you provide a unique clientID in your Broker Thing? Did you create a username/password and correctly enter it in the Broker Thing?

1 Like