Similar to the GET function in HTTP, subscribe is the method to obtain values with a huge difference: you do not have to be continuously asking the server for each value in your custom script.
For example, if a variable's value changes, Ubidots will automatically update you of any changes. Thus you will save data requests, processing time for your device, and overall project functionality as well as expenses. That's why MQTT is a communication protocol adviced to implement firmware routines to control actuators.


Keep Connection Alive

You will need to send a PINGREQ always that you implement a subscribe routine to our broker to avoid that Ubidots disconnects your device. The maximum allowed time to send it is 3 hours, so make sure that you set the keep alive parameter in your MQTT client to up to 180 minutes. For more information about MQTT keep alive please refer to section of this document