Hassio Built in MQTT issue socket errors

I have the latest version of Hassio on a pi3 with the duckdns and letsencrypt add-ons functioning correctly (to my knowledge). I am also running the MQTT add-on as well with this config:
{
“plain”: true,
“ssl”: true,
“anonymous”: false,
“logins”: [
{
“username”: “redacted”,
“password”: “redacted”
}
],
“customize”: {
“active”: false,
“folder”: “mosquitto”
},
“certfile”: “fullchain.pem”,
“keyfile”: “privkey.pem”
}

and in my config.yaml

mqtt:
broker: 192.168.1.13
port: 1883
client_id: home-assistant-1
username: redacted
password: redacted

MQTT log

starting version 3.2.2
1514476890: mosquitto version 1.4.12 (build date 2017-06-01 13:03:48+0000) starting
1514476890: Config loaded from /etc/mosquitto.conf.
1514476890: Opening ipv4 listen socket on port 1883.
1514476890: Opening ipv6 listen socket on port 1883.
1514476890: Opening ipv4 listen socket on port 8883.
1514476890: Opening ipv6 listen socket on port 8883.
1514476890: Warning: Mosquitto should not be run as root/administrator.
1514476890: New connection from 192.168.1.49 on port 1883.
1514476890: New client connected from 192.168.1.49 as livingroomsensor (c1, k15, u’ffyter’).
1514476890: New connection from 192.168.1.51 on port 1883.
1514476890: New client connected from 192.168.1.51 as garagesensor (c1, k15, u’ffyter’).
1514476892: New connection from 192.168.1.64 on port 1883.
1514476892: New client connected from 192.168.1.64 as DVES_57F89C (c1, k15, u’ffyter’).
1514476892: New connection from 192.168.1.7 on port 1883.
1514476892: New client connected from 192.168.1.7 as DVES_579C26 (c1, k15, u’ffyter’).
1514476892: New connection from 192.168.1.9 on port 1883.
1514476892: New client connected from 192.168.1.9 as DVES_583E23 (c1, k15, u’ffyter’).
1514476892: New connection from 192.168.1.3 on port 1883.
1514476892: New client connected from 192.168.1.3 as Garage1ESP (c1, k15, u’ffyter’).
1514476892: New connection from 192.168.1.50 on port 1883.
1514476892: New client connected from 192.168.1.50 as diningroomsensor (c1, k15, u’ffyter’).
1514476892: New connection from 192.168.1.48 on port 1883.
1514476892: New client connected from 192.168.1.48 as mainbedroomsensor (c1, k15, u’ffyter’).
1514476892: New connection from 192.168.1.52 on port 1883.
1514476892: New connection from 192.168.1.4 on port 1883.
1514476892: New client connected from 192.168.1.4 as zoeybedroomsensor (c1, k15, u’ffyter’).
1514476892: New client connected from 192.168.1.52 as basementsensor (c1, k15, u’ffyter’).
1514476892: New connection from 192.168.1.46 on port 1883.
1514476892: New client connected from 192.168.1.46 as zanderbedroomsensor (c1, k15, u’ffyter’).
1514476892: New connection from 192.168.1.54 on port 1883.
1514476892: New client connected from 192.168.1.54 as WallLEDs (c1, k15, u’ffyter’).
1514476892: New connection from 192.168.1.10 on port 1883.
1514476892: New client connected from 192.168.1.10 as PorchLEDs (c1, k15, u’ffyter’).
1514476893: New connection from 192.168.1.8 on port 1883.
1514476893: New client connected from 192.168.1.8 as DVES_57B963 (c1, k15, u’ffyter’).
1514476897: New connection from 192.168.1.66 on port 1883.
1514476897: New client connected from 192.168.1.66 as DVES_583769 (c1, k15, u’ffyter’).
1514476913: Socket error on client DVES_583769, disconnecting.
1514476914: Client PorchLEDs has exceeded timeout, disconnecting.
1514476914: Socket error on client PorchLEDs, disconnecting.
1514476914: New connection from 192.168.1.10 on port 1883.
1514476914: New client connected from 192.168.1.10 as PorchLEDs (c1, k15, u’ffyter’).
1514476918: Client diningroomsensor has exceeded timeout, disconnecting.
1514476918: Socket error on client diningroomsensor, disconnecting.
1514476921: New connection from 192.168.1.50 on port 1883.
1514476921: New client connected from 192.168.1.50 as diningroomsensor (c1, k15, u’ffyter’).
1514476924: New connection from 192.168.1.66 on port 1883.
1514476924: New client connected from 192.168.1.66 as DVES_583769 (c1, k15, u’ffyter’).
1514476944: New connection from 192.168.1.13 on port 1883.
1514476945: Socket error on client , disconnecting.
1514476945: New connection from 192.168.1.13 on port 1883.
1514476945: New client connected from 192.168.1.13 as home-assistant-1 (c1, k60, u’ffyter’).

I have Bruh multisensors and sonoff switches with the Tasmota firmware. All my MQTT Client names are unique as well. I can see all of the data and states correctly and control the switches. The thing that bothers me is that I get a ton of errors in the MQTT log. Everything is constantly connecting and disconnecting. Anyone know a fix for this?

So…I figured out the issue. All the connected devices were using pusubclient. By default the keepalive setting is set to 15s in the pub sub settings. I changed it to 60s and no more issues.

Hi I’m new to Home Assistant and im having the same issue where my mqtt says:
“Client testSonoff has exceeded timeout, disconnecting.”
Followed by a “socket error”

My client device is a Sonoff running tasmota 5.12
Your solutions mentioned changing pubsub settings to increase the keep alive time. Where do I go to do that?

Can you please elaborate? @ffyter

Thanks

Oh man it’s been awhile. It’s in your Arduino files. Look for pusubclient.h and in that file look for MQTT_KEEPALIVE and change it from 15 to 60.

1 Like

Ok. Thanks
I’ll give it a go tonight.

Did updating the MQTT_KEEPALIVE variable end up fixing the problem you guys were running into? Did you need to reflash your existing switches with this updated library?

I am running into the same problem with two sonoff switches that had been working for a number of monts.

I did reflash the switches. I have not had an issue since.