OpenZWave / qt-openzwave

QT5 Wrapper for OpenZWave
GNU Lesser General Public License v3.0
105 stars 30 forks source link

Duplicate mqtt-client-id's #206

Open yodalived opened 3 years ago

yodalived commented 3 years ago

https://github.com/OpenZWave/qt-openzwave/blob/7ebd43e246e97851ad20f2b1bb9c62bfd6a4a6ef/qt-ozwdaemon/mqttpublisher.cpp#L63

This line creates an mqtt client id of "qt-openzwave-0". If you have installations across multiple machines, their mqtt-client-id will be duplicated on the MQTT server. Since an MQTT server can only have unique client-id's, the older connection gets kicked off. In my instance, I have a two instances running in Docker connecting to the same MQTT server, both trying to connect with the same client id.

1616742757: New client connected from 192.168.105.219:45764 as qt-openzwave-0 (p2, c1, k60). 1616742765: New connection from 172.18.0.1:50662 on port 1883. 1616742765: Client closed its connection. 1616742765: New connection from 172.18.0.1:50666 on port 1883. 1616742765: Client qt-openzwave-0 already connected, closing old connection.

Can this be changed so that there is a short random number instead of 0 to allow multiple instances to connect to a single MQTT server?