eclipse / paho.mqtt.java

Eclipse Paho Java MQTT client library. Paho is an Eclipse IoT project.
https://eclipse.org/paho
Other
2.12k stars 883 forks source link

Not able to Enable and Disable the KeepAliveInterval while connection is active #482

Open Dharmaraj opened 6 years ago

Dharmaraj commented 6 years ago

Can you please let me know, Is there any way to enable and disable the KeepAliveInterval Or Change the keepAliveInterval time while connection is active.

And If Connection is active and If we changed the date time on Android Device , It will through the following exceptions and happen disconnect and reconnect issue:

throw ExceptionHelper.createMqttException(MqttException.REASON_CODE_WRITE_TIMEOUT); from ClientState.java file.

jpwsutton commented 6 years ago

The keep alive interval is something that is sent to the server on connection, there is no way to change it apart from disconnecting and reconnecting with a new keep alive interval.

That exception looks valid as we are using the devices internal clock to manage the keepalive, if the time is changed then it may cause our keepalive code to think that it's not had a response for more time that is allowed, or even that it's last ping was in the future. I'm not sure of any reasonable way to handle this apart from disconnecting and reconnecting.