Mqtt stops working

Hello, I’m using HA 100.3 on hassbian with python 3.7 and I have mosquitto 1.5.7 on the same device. Today it stops working and I don’t know how to solve.

Looking at the mosquitto status I see:

● mosquitto.service - Mosquitto MQTT v3.1/v3.1.1 Broker
  Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2019-12-30 17:46:30 UTC; 19min ago
     Docs: man:mosquitto.conf(5)
           man:mosquitto(8)
 Main PID: 509 (mosquitto)
    Tasks: 1 (limit: 2200)
   Memory: 1.5M
   CGroup: /system.slice/mosquitto.service
           └─509 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf

Dec 30 17:46:30 hassbian systemd[1]: Starting Mosquitto MQTT v3.1/v3.1.1 Broker...
Dec 30 17:46:30 hassbian systemd[1]: Started Mosquitto MQTT v3.1/v3.1.1 Broker.

Looking at the mosquitto.log file, I see sometimes any repeated errors like these:

 1523902373: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1523904174: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1523905390: Client home-assistant disconnected.
1523905390: Error in poll: Interrupted system call.
1523905390: mosquitto version 1.4.10 terminating
1523905399: mosquitto version 1.4.10 (build date Mon, 29 May 2017 13:43:29 +0100) starting
1523905399: Config loaded from /etc/mosquitto/mosquitto.conf.
1523905399: Opening ipv4 listen socket on port 1883.
1523905399: Opening ipv6 listen socket on port 1883.
1523905399: Opening ipv4 listen socket on port 8883.
1523905399: Opening ipv6 listen socket on port 8883.
1523905399: Connecting bridge cloudmqtt (m23.cloudmqtt.com:27618)
1523905399: Error creating bridge: Temporary failure in name resolution.
1523905399: Warning: Unable to connect to bridge cloudmqtt.

I have also this error, that’s more interesting imho:

 1523986453: Client home-assistant-1 has exceeded timeout, disconnecting.
1523986453: Socket error on client home-assistant-1, disconnecting.
1523986455: Client home-assistant-2 has exceeded timeout, disconnecting.
1523986455: Socket error on client home-assistant-2, disconnecting.
1523986466: Client home-assistant-3 has exceeded timeout, disconnecting.
1523986466: Socket error on client home-assistant-3, disconnecting.
1523986518: New connection from 192.168.(localip1) on port 1883.
1523986518: New client connected from 192.168.(localip1) as home-assistant-1 (c1, k15, u'homeassistant').
1523986525: New connection from 192.168.(localip2) on port 1883.
1523986525: New client connected from 192.168.(localip2) as home-assistant-3 (c1, k15, u'homeassistant').
1523986528: New connection from 192.168.(localip3) on port 1883.
1523986528: New client connected from 192.168.(localip3) as home-assistant-2 (c1, k15, u'homeassistant').
1523986737: Socket error on client eporedieis, disconnecting.
1523986768: Connecting bridge cloudmqtt (m23.cloudmqtt.com:27618)

And at the end of the file I found:

 1524415304: Client home-assistant disconnected.
1524415305: Error in poll: Interrupted system call.
1524415305: mosquitto version 1.4.10 terminating

In the configuration.yaml I have mqtt configuration:

mqtt:
  broker: 192.168.(samelocalipofHA)
  port: 1883
  client_id: home-assistant
  keepalive: 60
  username: !secret mqtt_user
  password: !secret mqtt_psw
  protocol: 3.1
  birth_message:
    topic: "tele/sonoff/LWT"
    payload: "Online"
    qos: 1
    retain: true
  will_message:
    topic: "tele/sonoff/LWT"
    payload: "Offline"
    qos: 1
    retain: true

All MQTT devices have Tasmota firmware, in the console, that are saying:

19:26:42 MQT: Attempting connection...
19:26:43 DNS: Query done. MQTT services found 0
19:26:43 MQT: Connect failed to :1883, rc -2. Retry in 10 sec

My opinion: I think Mosquitto is working correctly and the problem is the connection from it and the mqtt devices. The stranger thing is that I’ve not updated nothing and so I don’t know where I have to look for the solution. Could anyone help me please? Thank you very much!

Can you connect with mosquitto_pub?

Yes, I can :thinking:

I had tons of problems with Tasmota and MQTT a few months ago, have they fixed that problem with the kernel? I solved all my problems by using esphome on all the devices instead. My errors were similar to yours.

1 Like

@NK553 I agree, and did the same, though i never used an external broker, it was reliable but sometime it was slow and sometimes it did strange things, i finally RIP tasmota from all my lights and switch the last 2 were ifan02 that are now on Esphome.
The only thing i use tasmota and MQTT is on my Sonof RF Bridges, door sensor and 4 button remotes

Thank you very much to all!