Trying to fix disconnection issue using the paho-mqtt loop...

This commit is contained in:
B.J. Dweck 2020-10-22 10:50:24 +02:00
parent 97f8bdd3ac
commit cd51f18eab

View File

@ -32,7 +32,7 @@ def main():
config = configparser.ConfigParser() config = configparser.ConfigParser()
configuration_file_path = config_path + "torch.conf" configuration_file_path = config_path + "torch.conf"
print("Reading configuration file at '%s'" % (configuration_file_path)) print("Reading configuration file at '%s'" % configuration_file_path)
config.read(configuration_file_path) config.read(configuration_file_path)
tor_proxy_host = config['tor'].get('ProxyHost', fallback="127.0.0.1") tor_proxy_host = config['tor'].get('ProxyHost', fallback="127.0.0.1")
@ -76,12 +76,14 @@ def main():
print("Published payload!") print("Published payload!")
pub_client.disconnect() pub_client.disconnect()
def on_disconnect(): def on_disconnect(pub_client):
print("Disconnected!") print("Disconnected!")
pub_client.loop_stop()
client = mqtt.Client() client = mqtt.Client()
client.on_publish = on_publish client.on_publish = on_publish
client.on_disconnect = on_disconnect client.on_disconnect = on_disconnect
client.loop_start()
protocol = "mqtt" protocol = "mqtt"