You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 11, 2020. It is now read-only.
Hi I have a mqtt broker up and running. I am connecting to it from python using paho-mqtt.
Code
def on_connect(client, userdata, flags, rc):
if rc==0:
print("connected OK Returned code=",rc)
else:
print("Bad connection Returned code=",rc)
print("Subscribing to topic","data/#")
client.subscribe("data/#")
def on_disconnect(client, userdata, rc):
print("Client Got Disconnected")
if rc != 0:
print('Unexpected MQTT disconnection. Will auto-reconnect')
else:
print('rc value:' + str(rc))
broker_address="ip"
port = 'port'
print("creating new instance")
client = mqtt.Client(clean_session=True) #create new instance
client.on_connect = on_connect
client.on_message = on_message #attach function to callback
client.on_disconnect = on_disconnect
print("connecting to broker")
client.connect(broker_address, port=port,) #connect to broker
client.loop_forever() #stop the loop
I am using the same code in multiple scripts ,connecting to broker and subscribing to a topic. The frequency of disconnection was less when there were 5-6 scripts. Like 2-3 times an hour. Now, I have around 12-13 scripts connecting to the broker and frequency of disconnects has increased significantly.Its disconnecting once in every 5 minutes. Is there some thing wrong with the connection in the scripts or its about the broker. Is there any limitation on connections a mqtt broker can handle?
Thanks
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi I have a mqtt broker up and running. I am connecting to it from python using paho-mqtt.
Code
I am using the same code in multiple scripts ,connecting to broker and subscribing to a topic. The frequency of disconnection was less when there were 5-6 scripts. Like 2-3 times an hour. Now, I have around 12-13 scripts connecting to the broker and frequency of disconnects has increased significantly.Its disconnecting once in every 5 minutes. Is there some thing wrong with the connection in the scripts or its about the broker. Is there any limitation on connections a mqtt broker can handle?
Thanks
The text was updated successfully, but these errors were encountered: