Mqtt embedded broker not responding

Hi All,

I just starting using openhab a week ago and its really awesome.

I am using MQTT broker and ESP32s to control Lights in my house.

Setup:
4 Lights and 1 RGB LED strip.

2 ESPs connected to my MQTT broker out of which 1 is connected with relay to control 4 lights and another one is connected to LED strip which controls color.

when i publish ON/OFF command to Lights. (MQTT Thing which has ON/OFF type channel) it works fine, similarly for LED sript i am using MQTT Text Like Channel where i am sending r,g,b values.

It all works fine but today I tried to control my lights and LED strip nothing was working for me then I checked in Paper UI can Could see my Devices were Offline due to some communication error.

In Paper UI I cloud see all devices were offline other then MQTT Broker. but when i checked log file could see broker was also offline which was not reflecting in paper UI:


When I checked Openhab Log file I could see below Error:

2019-08-09 04:20:58.644 [ERROR] [o.client.mqttv3.internal.ClientState] - embedded-mqtt-broker: Timed out as no write activity, keepAlive=60,000 lastOutboundActivity=1,565,320,644,652 lastInboundActivity=1,565,320,644,654 time=1,565,320,858,636 lastPing=1,565,320,644,652
2019-08-09 04:20:58.659 [INFO ] [ansport.mqtt.internal.ClientCallback] - MQTT connection to ‘127.0.0.1’ was lost
org.eclipse.paho.client.mqttv3.MqttException: Timed out while waiting to write messages to the server
at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:31) ~[198:org.eclipse.paho.client.mqttv3:1.2.0]
at org.eclipse.paho.client.mqttv3.internal.ClientState.checkForActivity(ClientState.java:705) ~[198:org.eclipse.paho.client.mqttv3:1.2.0]
at org.eclipse.paho.client.mqttv3.internal.ClientComms.checkForActivity(ClientComms.java:784) [198:org.eclipse.paho.client.mqttv3:1.2.0]
at org.eclipse.paho.client.mqttv3.internal.ClientComms.checkForActivity(ClientComms.java:770) [198:org.eclipse.paho.client.mqttv3:1.2.0]
at org.eclipse.paho.client.mqttv3.TimerPingSender$PingTask.run(TimerPingSender.java:77) [198:org.eclipse.paho.client.mqttv3:1.2.0]
at java.util.TimerThread.mainLoop(Timer.java:555) [?:?]
at java.util.TimerThread.run(Timer.java:505) [?:?]
2019-08-09 04:20:58.684 [WARN ] [r.internal.EmbeddedBrokerServiceImpl] - Embedded broker offline
org.eclipse.paho.client.mqttv3.MqttException: Timed out while waiting to write messages to the server
at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:31) ~[198:org.eclipse.paho.client.mqttv3:1.2.0]
at org.eclipse.paho.client.mqttv3.internal.ClientState.checkForActivity(ClientState.java:705) ~[198:org.eclipse.paho.client.mqttv3:1.2.0]
at org.eclipse.paho.client.mqttv3.internal.ClientComms.checkForActivity(ClientComms.java:784) [198:org.eclipse.paho.client.mqttv3:1.2.0]
at org.eclipse.paho.client.mqttv3.internal.ClientComms.checkForActivity(ClientComms.java:770) [198:org.eclipse.paho.client.mqttv3:1.2.0]
at org.eclipse.paho.client.mqttv3.TimerPingSender$PingTask.run(TimerPingSender.java:77) [198:org.eclipse.paho.client.mqttv3:1.2.0]
at java.util.TimerThread.mainLoop(Timer.java:555) [?:?]
at java.util.TimerThread.run(Timer.java:505) [?:?]
2019-08-09 04:21:00.947 [ERROR] [io.moquette.server.Server ] - Moquette is not started, MQTT message interceptor cannot be removed. InterceptorId=collectmetrics


After that i restarted openhab.service what fixed the issue, Please help me understand If I can write script to bounce (restart) openhab service daily or twice a day so that such issue can be avoided.

I am not always around the home and my family cannot fix technical issue by there own,
they just use Openhab mobile App to control devices.

Please assist, How can I avoid such situation in future.

A better solution would be to

  1. file an issue on the embedded broker, see How to file an Issue. I believe the repo is openhab2-addons.

  2. Switch to using an external MQTT broker like Mosquitto.

In all likelihood the root of the problem is upstream from openHAB so it might take some time to be fixed. Mosquitto is a pretty rock solid broker and it will be a whole lot less work to install and configure it than to write something that reboots your OH every night.