async-mqtt-client icon indicating copy to clipboard operation
async-mqtt-client copied to clipboard

mqtt reconnect keeps sessions

Open unbreakmat opened this issue 5 years ago • 0 comments

im a little bit stuck. So i made a webserver where i can put in all the variables, who are then saved with spiffs in the flash (in case of a reboot), who then cals the mqttclient.connect(); If the connects suceeded, we subscribe to a topic from the broker server (for example a light) This is confirmed by my code in serial: 23:50:51.496 -> [MQTT] Subscribe acknowledged - packetId 1

buth the problem im facing : If we have a connection and let say we go back to that form to for example change my client id or put in a user and pass wo are also configured on the broker server to work. It does reconnects but i see that im having now 2 session id's? 00:02:46.848 -> [MQTT] Subscribe acknowledged - packetId 1 00:02:46.848 -> [MQTT] Subscribe acknowledged - packetId 1 00:02:46.943 -> [MQTT] Subscribe acknowledged - packetId 2 00:02:46.992 -> [MQTT] Subscribe acknowledged - packetId 2

Also session 1 is like "duplicated" So the first one of the first connect is stil active, i think?

This happens also when i put in random things for the second time and correct vars in the third time, resulting in 3 sessions 00:03:44.768 -> [MQTT] Subscribe acknowledged - packetId 1 00:03:44.768 -> [MQTT] Subscribe acknowledged - packetId 1 00:03:44.864 -> [MQTT] Subscribe acknowledged - packetId 1 00:03:44.864 -> [MQTT] Subscribe acknowledged - packetId 2 00:03:44.909 -> [MQTT] Subscribe acknowledged - packetId 2 00:03:45.003 -> [MQTT] Subscribe acknowledged - packetId 2 00:03:45.003 -> [MQTT] Subscribe acknowledged - packetId 3 00:03:45.098 -> [MQTT] Subscribe acknowledged - packetId 3 00:03:45.098 -> [MQTT] Subscribe acknowledged - packetId 3

Can someone explain me how to completely clear previously connections? im missing something i think

unbreakmat avatar Sep 27 '20 22:09 unbreakmat