forked from platypush/platypush
Don't create an MQTT client connection if there are no topics to subscribe.
If we open multiple connections from multiple MQTT-based backends to the same host, with some of them having no topics subscribed, Paho-MQTT can mess up which client is supposed to receive which message and we may end up with lost messages on the platypush_bus_mqt/<host> topic.
This commit is contained in:
parent
51e6d95205
commit
201bb5986f
1 changed files with 2 additions and 2 deletions
|
@ -319,8 +319,8 @@ class MqttBackend(Backend):
|
||||||
def run(self):
|
def run(self):
|
||||||
super().run()
|
super().run()
|
||||||
|
|
||||||
if self.host:
|
if self.host and self.subscribe_default_topic:
|
||||||
topics = [self.topic] if self.subscribe_default_topic else []
|
topics = [self.topic]
|
||||||
client = self._get_client(host=self.host, port=self.port, topics=topics, username=self.username,
|
client = self._get_client(host=self.host, port=self.port, topics=topics, username=self.username,
|
||||||
password=self.password, client_id=self.client_id,
|
password=self.password, client_id=self.client_id,
|
||||||
tls_cafile=self.tls_cafile, tls_certfile=self.tls_certfile,
|
tls_cafile=self.tls_cafile, tls_certfile=self.tls_certfile,
|
||||||
|
|
Loading…
Reference in a new issue