hivemq-mqtt-client
hivemq-mqtt-client copied to clipboard
Send PING manually
Problem or use case
On Android automatic pings won't be sent due to battery restrictions. But the device can be woken up in regular intervals to send a manual ping. The control should be from outside of the library because you need to know as a developer when the ping response has been received. Only then can you send the device back to sleep.
Preferred solution or suggestions
something like mqtt5SynchronousClient.sendPing()
Hi @canique @SgtSilvio
For the current version, Is there a way to send message like ping , or can i keep client alive forever?
Hi @gcdd1993 Pings are sent automatically when the communication between the broker and client is inactive. Currently it is only not possible to trigger a ping manually via the API.
@SgtSilvio OK, I understand, besides, how long is the default interval of the ping ?
@gcdd1993 The interval is defined by the keep alive value you specify in the connect message. The default keep alive interval is 60 seconds.