Mosquito in Home assistant is disconnect
I can't find patterns, I have 7 switches that are identical with two keys. They constantly lost connection in Mosquito in a random order, no patterns can be found. At the same time, switches with a tuya cloud in the application work perfectly and without problems.

I use home assistant addon for mosquito and tuyagateway logs of mosquito:
1598279107: Socket error on client auto-7539C211-9308-0E79-A27D-28167D3898EF, disconnecting. 1598279107: Socket error on client auto-F3166C67-4D59-35E0-AC97-D1F766D69CF2, disconnecting. 1598279107: Socket error on client auto-A682731D-E0D0-BEEC-74D2-8C5D2AB4F6D6, disconnecting. 1598279107: Socket error on client auto-BBDBA8BD-120A-291A-6B29-C55F27794EDD, disconnecting. 1598279107: Socket error on client auto-B40A1611-CB56-82B7-3D9E-77472A474024, disconnecting. 1598279107: Socket error on client auto-0B93A3C6-47D5-9D11-8CDD-94BE74E17E9D, disconnecting. 1598279110: New connection from 172.30.33.3 on port 1883. [INFO] found addons on local database 1598279110: New client connected from 172.30.33.3 as auto-52AF328C-2BF4-C70D-3EC4-0EE09AEC6DE4 (p2, c1, k60, u'addons'). 1598279111: New connection from 172.30.33.3 on port 1883. 1598279111: New client connected from 172.30.33.3 as auto-C8A8567A-6483-EDFB-E67B-726D422C3FBC (p2, c1, k60, u'addons'). 1598279111: New connection from 172.30.33.3 on port 1883. 1598279111: New client connected from 172.30.33.3 as auto-046D612F-6DEA-6E37-3E94-A9061AC76A54 (p2, c1, k60, u'addons'). 1598279111: New connection from 172.30.33.3 on port 1883. 1598279111: New connection from 172.30.33.3 on port 1883. 1598279111: New connection from 172.30.33.3 on port 1883. 1598279111: New client connected from 172.30.33.3 as auto-C6EB8AE4-7F06-1CF8-663C-4A9FC05BA64D (p2, c1, k60, u'addons'). 1598279111: New client connected from 172.30.33.3 as auto-B206D617-3439-8750-BFE8-79945873D3B0 (p2, c1, k60, u'addons'). 1598279111: New client connected from 172.30.33.3 as auto-369AEC5C-9BD3-F8B4-7264-19FFC5AE9B72 (p2, c1, k60, u'addons'). 1598279111: New connection from 172.30.33.3 on port 1883. 1598279111: New connection from 172.30.33.3 on port 1883. 1598279111: New client connected from 172.30.33.3 as auto-A5CB1216-C263-8C65-80C4-52399ED14E84 (p2, c1, k60, u'addons'). 1598279111: New client connected from 172.30.33.3 as auto-29AE2379-2899-F7EF-3AC8-DEB76ED2C5BB (p2, c1, k60, u'addons'). 1598279111: New connection from 172.30.33.3 on port 1883 1598279111: New client connected from 172.30.33.3 as auto-EF4B9FB6-AB91-2F2A-FBE6-87D4E853331B (p2, c1, k60, u'addons'). 1598279112: New connection from 172.30.33.3 on port 1883. 1598279112: New client connected from 172.30.33.3 as auto-F0C7595E-D230-72BA-FE30-93439BD939A6 (p2, c1, k60, u'addons'). 1598279112: New connection from 172.30.33.3 on port 1883. 1598279112: New client connected from 172.30.33.3 as auto-7A8D245C-39A3-0A5F-6726-17D9CBEE2A7B (p2, c1, k60, u'addons'). 1598279113: New connection from 172.30.33.3 on port 1883. 1598279113: New client connected from 172.30.33.3 as auto-A1562F65-FADB-17AD-D0CF-9BD6D757AE28 (p2, c1, k60, u'addons'). 1598279114: New connection from 172.30.33.3 on port 1883. 1598279114: New client connected from 172.30.33.3 as auto-2A936B37-211C-380F-B9F5-421BBB585806 (p2, c1, k60, u'addons'). 1598279114: New connection from 172.30.33.3 on port 1883. 1598279114: New client connected from 172.30.33.3 as auto-11C7E072-8667-83EF-7506-C467395E7A74 (p2, c1, k60, u'addons'). 1598279115: New connection from 172.30.33.3 on port 1883. 1598279115: New client connected from 172.30.33.3 as auto-1DF1BC3A-362B-BBF4-D0CD-2B72A6B58A56 (p2, c1, k60, u'addons'). 1598279115: New connection from 172.30.33.3 on port 1883. 1598279115: New client connected from 172.30.33.3 as auto-7848EC66-0F43-1252-3290-125586C2E72C (p2, c1, k60, u'addons'). 1598279201: Client auto-046D612F-6DEA-6E37-3E94-A9061AC76A54 has exceeded timeout, disconnecting. 1598279201: Client auto-369AEC5C-9BD3-F8B4-7264-19FFC5AE9B72 has exceeded timeout, disconnecting. 1598279201: Client auto-29AE2379-2899-F7EF-3AC8-DEB76ED2C5BB has exceeded timeout, disconnecting. 1598279202: Client auto-C6EB8AE4-7F06-1CF8-663C-4A9FC05BA64D has exceeded timeout, disconnecting. 1598279202: Client auto-B206D617-3439-8750-BFE8-79945873D3B0 has exceeded timeout, disconnecting. 1598279202: Client auto-A5CB1216-C263-8C65-80C4-52399ED14E84 has exceeded timeout, disconnecting. 1598279202: Client auto-EF4B9FB6-AB91-2F2A-FBE6-87D4E853331B has exceeded timeout, disconnecting. 1598279454: Saving in-memory database to /data/mosquitto.db. 1598281255: Saving in-memory database to /data/mosquitto.db
and tuyagateway logs
2020-08-24 19:09:12,670 DEBUG (Thread-25) [tuyaface.tuyaclient] (192.168.1.71) PONG 2020-08-24 19:09:14,945 DEBUG (Thread-40) [tuyaface.tuyaclient] (192.168.1.73) PING 2020-08-24 19:09:14,947 DEBUG (Thread-40) [tuyaface] (192.168.1.73) sending msg (seq 893): [9:HEART_BEAT] payload: [None] 2020-08-24 19:09:14,956 DEBUG (Thread-40) [tuyaface] (192.168.1.73) received msg (seq 0): [9:HEART_BEAT] rc: [0] payload: [None] 2020-08-24 19:09:14,957 DEBUG (Thread-40) [tuyaface.tuyaclient] (192.168.1.73) PONG 2020-08-24 19:09:17,069 DEBUG (Thread-43) [tuyaface.tuyaclient] (192.168.1.75) PING 2020-08-24 19:09:17,071 DEBUG (Thread-43) [tuyaface] (192.168.1.75) sending msg (seq 895): [9:HEART_BEAT] payload: [None] 2020-08-24 19:09:17,081 DEBUG (Thread-43) [tuyaface] (192.168.1.75) received msg (seq 0): [9:HEART_BEAT] rc: [0] payload: [None] 2020-08-24 19:09:17,082 DEBUG (Thread-43) [tuyaface.tuyaclient] (192.168.1.75) PONG 2020-08-24 19:09:17,937 DEBUG (Thread-28) [tuyaface.tuyaclient] (192.168.1.109) PING 2020-08-24 19:09:17,938 DEBUG (Thread-28) [tuyaface] (192.168.1.109) sending msg (seq 486): [9:HEART_BEAT] payload: [None] 2020-08-24 19:09:18,007 DEBUG (Thread-28) [tuyaface] (192.168.1.109) received msg (seq 0): [9:HEART_BEAT] rc: [0] payload: [None] 2020-08-24 19:09:18,008 DEBUG (Thread-28) [tuyaface.tuyaclient] (192.168.1.109) PONG 2020-08-24 19:09:18,568 DEBUG (Thread-1) [paho.mqtt.client] Sending PINGREQ 2020-08-24 19:09:18,570 DEBUG (Thread-1) [paho.mqtt.client] Received PINGRESP 2020-08-24 19:09:19,035 DEBUG (Thread-31) [tuyaface.tuyaclient] (192.168.1.72) PING 2020-08-24 19:09:19,036 DEBUG (Thread-31) [tuyaface] (192.168.1.72) sending msg (seq 896): [9:HEART_BEAT] payload: [None] 2020-08-24 19:09:19,036 DEBUG (Thread-37) [tuyaface.tuyaclient] (192.168.1.74) PING 2020-08-24 19:09:19,037 DEBUG (Thread-37) [tuyaface] (192.168.1.74) sending msg (seq 891): [9:HEART_BEAT] payload: [None] 2020-08-24 19:09:19,091 DEBUG (Thread-37) [tuyaface] (192.168.1.74) received msg (seq 0): [9:HEART_BEAT] rc: [0] payload: [None] 2020-08-24 19:09:19,091 DEBUG (Thread-37) [tuyaface.tuyaclient] (192.168.1.74) PONG 2020-08-24 19:09:19,092 DEBUG (Thread-31) [tuyaface] (192.168.1.72) received msg (seq 0): [9:HEART_BEAT] rc: [0] payload: [None] 2020-08-24 19:09:19,092 DEBUG (Thread-31) [tuyaface.tuyaclient] (192.168.1.72) PONG 2020-08-24 19:09:19,402 DEBUG (Thread-34) [tuyaface.tuyaclient] (192.168.1.76) PING 2020-08-24 19:09:19,403 DEBUG (Thread-34) [tuyaface] (192.168.1.76) sending msg (seq 893): [9:HEART_BEAT] payload: [None] 2020-08-24 19:09:19,414 DEBUG (Thread-34) [tuyaface] (192.168.1.76) received msg (seq 0): [9:HEART_BEAT] rc: [0] payload: [None] 2020-08-24 19:09:19,548 DEBUG (Thread-34) [tuyaface.tuyaclient] (192.168.1.76) PONG 2020-08-24 19:09:19,692 DEBUG (Thread-25) [tuyaface.tuyaclient] (192.168.1.71) PING 2020-08-24 19:09:19,693 DEBUG (Thread-25) [tuyaface] (192.168.1.71) sending msg (seq 895): [9:HEART_BEAT] payload: [None] 2020-08-24 19:09:19,916 DEBUG (Thread-25) [tuyaface] (192.168.1.71) received msg (seq 0): [9:HEART_BEAT] rc: [0] payload: [None] 2020-08-24 19:09:19,916 DEBUG (Thread-25) [tuyaface.tuyaclient] (192.168.1.71) PONG 2020-08-24 19:09:20,729 DEBUG (Thread-24) [paho.mqtt.client] Sending PINGREQ 2020-08-24 19:09:20,730 DEBUG (Thread-24) [paho.mqtt.client] Received PINGRESP 2020-08-24 16:09:20,951 DEBUG [paho.mqtt.client] Sending PINGREQ 2020-08-24 16:09:20,952 DEBUG [paho.mqtt.client] Received PINGRESP 2020-08-24 19:09:21,976 DEBUG (Thread-40) [tuyaface.tuyaclient] (192.168.1.73) PING 2020-08-24 19:09:21,976 DEBUG (Thread-40) [tuyaface] (192.168.1.73) sending msg (seq 894): [9:HEART_BEAT] payload: [None] 2020-08-24 19:09:21,977 DEBUG (Thread-30) [paho.mqtt.client] Sending PINGREQ 2020-08-24 19:09:21,977 DEBUG (Thread-30) [paho.mqtt.client] Received PINGRESP 2020-08-24 19:09:22,358 DEBUG (Thread-40) [tuyaface] (192.168.1.73) received msg (seq 0): [9:HEART_BEAT] rc: [0] payload: [None] 2020-08-24 19:09:22,358 DEBUG (Thread-40) [tuyaface.tuyaclient] (192.168.1.73) PONG
when I restart mosquito brocker all switch is connected, but after 5-10 seconds some switch is disconnected random
From your tuyagateway logs I don't see any disconnects. Only a heartbeat there. Some tuya devices break the connection with the gateway when the smartlife app connects to it. Maybe that is the problem here.
I reinstall mosquito now, will see
I dont open tuya smart app when test tuyagateway
But what mean socket error in mqtt logs?
1598306720: New client connected from 172.30.32.1 as auto-EB387B60-070E-1C7B-3688-7A474054365C (p2, c1, k60, u'mqtt'). 1598306955: Socket error on client auto-EB387B60-070E-1C7B-3688-7A474054365C, disconnecting. 1598306967: New connection from 172.30.32.1 on port 1883.
after reinstall mosquitto all work good. May be mosquitto remember previos name of switch, when I test it and reinstall help to forget it.
except one problem: sometime when I switch on in home assistant switch turns itself off immediately. I see it two time now, I have 7 switches today.
I wonder if there’s a way to delay the start of the Mosquito when Home Assistant starts up? I need to do this with HomeKit