0
votes

I am confused by the programming model of mqtt. My goal is to deploy a client that periodically retrieves sensor data and publish them on a topic via mqtt paho client.

In the code-examples from paho after every publication they disconnects, but i have also see examples where the client published data without a disconnect message sending after each sensor data publication. What is the best approach ?

1
As it stands this question is too broad to get a proper answer. Please read the guidelines on asking good questions - stackoverflow.com/help/dont-askhardillb
but this is a exact questionSadik Hasan
"what is the best approach?" is very broad. It depends entirely on your situation.ralight
What is the difference i mean if i publish every 2 seconds sensordata, should i send a DISCONNECT-Packet and then resend again via PUBLISH-Packet?Sadik Hasan

1 Answers

0
votes

If you want to send sensor data frequently, try maintaining the connection. Otherwise you need to send keepalive message regularly.