I'm currently working on a small "Panic Button" app supposed to operate in a medical facility. As one of the project's assumptions is to be Internet-independent, I've decided to go for MQTT with a server set up in the local WLAN.
I've implemented the Paho Android Service and it works pretty good. Up to a certain point. Once I lock the device and turn off the sreen, exactly after one minute the client gets disconnected. As I've set MQTT options to KeepAlive interval of 30s, this must be caused by Android itself, probably going into its lock-sleep. I'm obtaining the same results on couple of different smartphones, so it is probably also not user settings - related.
I'd rather avoid setting up an auto-reconnect procedure in
public class ServerCallback implements MqttCallback
{
public void connectionLost(Throwable cause) {
...
}
}
Because I want to use this method to prompt an error dialog once connection is lost due to less predictable reasons.
If so, what options do I have to prevent this disconnection?
EDIT:
Additional observation of mine is that as long as the device is plugged in and charging, disconnection does not occur.