|Re: [paho-dev] Android - Paho Mqtt client does not receive messages once network connectivity changes (mobile data disabled and enabled again)|
The Java client is at the mercy of the underlying networking API to
a certain extent. When publish is called, it will write an MQTT
packet to the socket. If that write fails, then connection lost
will be called, if that write works then the client library will
carry on. The difference in behaviour you are seeing is because the
networking libraries are behaving differently in these
Keepalive is meant to help with this. Under certain circumstances a TCP connection may appear to be live when it is not. This is especially possible on mobile or satellite connected devices - you can't expect the networking APIs to work exactly the same in all circumstances. Keepalive sends a ping packet to the server and expects a response - if that response is not received, the session is assumed to be closed.
If you set the keepalive interval to say 10 seconds, then the connection should be recognised as broken within 15 to 20 seconds.
On 08/10/2014 06:09 PM, Prashant Kedia wrote:
-- Ian Craggs icraggs@xxxxxxxxxx IBM United Kingdom Committer on Paho, Mosquitto
Back to the top