Its been only a week I started using Manjaro Gnome, and I’m new to forums. So I’m working on a project related to MQTT, for which I executed two basic scripts of python. On executing the publisher script there is no issue, but when the subscriber script is executed the whole system got froze. Then I had to force shutdown it. I tried again after rebooting, still same issue.
Then I tried this scripts on windows, and there were no issue got the expected results.
These are the scripts
publisher.py
import paho.mqtt.client as mqtt
from random import randrange, uniform
import time
mqttBroker ="mqtt.eclipseprojects.io"
client = mqtt.Client("Temperature_Inside")
client.connect(mqttBroker)
while True:
randNumber = uniform(20.0, 21.0)
client.publish("TEMPERATURE", randNumber)
print("Just published " + str(randNumber) + " to topic TEMPERATURE")
time.sleep(1)
subscriber.py
import paho.mqtt.client as mqtt
import time
def on_message(client, userdata, message):
print("received message: " ,str(message.payload.decode("utf-8")))
mqttBroker ="mqtt.eclipseprojects.io"
client = mqtt.Client("Smartphone")
client.connect(mqttBroker)
client.loop_start()
client.subscribe("TEMPERATURE")
client.on_message = on_message
time.sleep(30)
client.loop_stop()