I am using python paho mqtt client to subscribe the MQTT broker to get the data and I am publishing the data through ESP32 using pubsubclient.h.
Data frequency is 1000 messages per sec. for testing I published 100000 messages and I used python paho mqtt to subscribe and collect data. I tested several times but I am getting 22000-30000 messages out of 100000 message.
This the code I am using to subscribe the broker:
import paho.mqtt.client as mqtt
def on_connect(client, userdata, flags, rc):
if rc == 0:
print("Connected to broker")
client.subscribe("pub_test",2)
else:
print("Connection failed")
def on_message(client, userdata, message):
print (message.payload)
def updateMqtt():
client = mqtt.Client(client_id="Sathish", clean_session=False, userdata=None, transport="tcp")
#client = mqtt.Client()
client.on_connect= on_connect
print("after on connect")#attach function to callback
client.on_message= on_message
print("after on message")#attach function to callback
client.connect("192.168.3.101", port=1883)
client.loop_forever()
# client.loop_start()
updateMqtt()