Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Paho » Paho Java client, turning off automatic ping messages
Paho Java client, turning off automatic ping messages [message #930282] Tue, 02 October 2012 07:08 Go to next message
tobi hofer is currently offline tobi hoferFriend
Messages: 2
Registered: October 2012
Junior Member
Hi guys,
Im currently working on an android mqtt based app using the paho java client. Here is my Question:
Is there a qay to turn of the automatically created ping messages that the client sends the broker every "keepAliveInterval" seconds?
Since the CPU of my device can go to sleep every now and then i need to implement my own ping service, wich wakes the CPU when its time to ping. The "problem" is that now i ping twice when the cpu is running.It would be nice to have an option in the ConnectionOptions to tell the client that i gonna do the pinging stuff on my own.

kind regards!
Tobi
Re: Paho Java client, turning off automatic ping messages [message #930593 is a reply to message #930282] Tue, 02 October 2012 13:10 Go to previous messageGo to next message
Dave Locke is currently offline Dave LockeFriend
Messages: 2
Registered: October 2012
Junior Member
Setting the keepalive value to 0 using method setKeepAliveInterval on the connect options class will stop the client from sending pings. The value of 0 will be passed to the MQTT server telling it not to expect any ping packets and hence not to do any "keep alive" processing - which I suspect is not what you are looking for.

If any MQTT packet (not just ping) is sent within a keepalive interval the MQTT client will reset the timer which it uses to send a ping i.e. it minimises when it sends pings to only when no MQTT packet has been sent within a keepalive interval.

How are you sending a ping at the moment? The MQTT client does not have a public interface for sending a ping?

If a ping method was added then I believe the following would provide what you are looking for?

1) MQTT app sets the keepalive to value x
2) MQTT app has logic to wake up slightly less than x
3) MQTT app invokes the MQTT ping - this would reset the internal keepalive timer in the client meaning it would then not send its own ping.

Until a ping method is added publishing a message or re-subscribing would have the same effect.
Re: Paho Java client, turning off automatic ping messages [message #932693 is a reply to message #930282] Thu, 04 October 2012 10:37 Go to previous message
tobi hofer is currently offline tobi hoferFriend
Messages: 2
Registered: October 2012
Junior Member
oh... thank you,
I didnt know that the client stops pinging if any message was sent to the server within the last keepAlive period.

The problem was that my self managed ping message was sent shortly after the ping from the client. so it was a little too late. I changed the ping period that my app pings shortly before the mqtt client and that solved the problem.

thanks for your advice!
Previous Topic:Welcome to eclipse.paho
Next Topic:Paho SSL with pre-shared key
Goto Forum:
  


Current Time: Thu Apr 25 00:00:26 GMT 2024

Powered by FUDForum. Page generated in 0.03466 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top