Using the foris-client (mqtt) does not clean up subscriptions
Hi,
i did some monitoring of the $SYS/broker/retained messages/count and $SYS/broker/subscriptions/count channels to check whether my continuous requests against the foris-bus (mqtt) are generating some "data leak". The result was an increasing subscription count every time i invoked the client.
I did some research and the main reason is probably the setting "clean_session=False" in the mqtt implementation is preserving the subscriptions for a reconnect. but as the client is always generating a new client id, it is never reused, when invoked by hand e.g. with foris-client-wrapper. also the unsubscribe in the mqtt (ReplyListener) implementation is never called when the client exits.
In a permanent running program this is probably no issue, but when the client is used e.g. in a cronjob this could lead to a increased memory usage of mosquito, with other side effects.
I modified the client to use clean_session = True and this behavior is gone, as mosquito is cleaning the sessions after the disconnect. So i think there are two solutions to this problem, make the clean_session configurable and default to true and only use none clean session for long running programs, or fix the cleanup behavior, e.g. moving from run_loop_forever to loop_start/loop_stop. so it can be cleaned up before the disconnect.
I'm quite new to mqtt / paho so maybe i'm wrong here.
Regards Christoph - (loom - turris forum)