hivemq-mqtt-client icon indicating copy to clipboard operation
hivemq-mqtt-client copied to clipboard

Send PING manually

Open canique opened this issue 5 years ago • 5 comments

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()

canique avatar Jun 24 '20 17:06 canique

Hi @canique @SgtSilvio For the current version, Is there a way to send message like ping , or can i keep client alive forever?

gcdd1993 avatar Jan 14 '21 03:01 gcdd1993

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 avatar Jan 14 '21 09:01 SgtSilvio

@SgtSilvio OK, I understand, besides, how long is the default interval of the ping ?

gcdd1993 avatar Jan 14 '21 09:01 gcdd1993

@gcdd1993 The interval is defined by the keep alive value you specify in the connect message. The default keep alive interval is 60 seconds.

SgtSilvio avatar Jan 14 '21 10:01 SgtSilvio