Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] Manually sending ping using Paho MQTT client

For the reference of subscribers to this list, it looks like this discussion has also been posted on Stack Overflow:
http://stackoverflow.com/questions/10065624/how-to-send-ping-using-ecipse-paho-mqtt-client

I know @dalelane and @sd_nicholas have done a lot of work with MQTT on Android - and their articles are linked from the mqtt.org wiki page http://mqtt.org/wiki/doku.php/mqtt_on_the_android_platform - however that page was compiled pre-Paho.

I seem to remember a discussion of making a wrapper to get around this issue (when I was at IBM) but I may not be recalling the solution correctly.

Andy 

-- 
Andy Piper | Farnborough, Hampshire (UK)
blog: http://andypiper.co.uk   |   skype: andypiperuk
twitter: @andypiper  |  images: http://www.flickr.com/photos/andypiper



On Sunday, 8 April 2012 at 20:17, Dr. Mehdi Hasan Khan wrote:

> Hello,
> 
> First of all, thank you for releasing the source of MQTT client code. We've just started building our own push notification system for Android and found this gem. Needless to say, this Eclipse Paho project is really exciting. 
> 
> The problem with Android is, if the CPU is in sleep state, the client may not get the chance to send ping at its set interval. The workaround is using AlarmManager to wake it up and get the job done. The Android documentation says: "The Alarm Manager holds a CPU wake lock as long as the alarm receiver's onReceive() method is executing. This guarantees that the phone will not sleep until you have finished handling the broadcast. Once onReceive() returns, the Alarm Manager releases this wake lock. This means that the phone will in some cases sleep as soon as your onReceive() method completes." 
> http://developer.android.com/reference/android/app/AlarmManager.html
> 
> I need to be sure that I could send the ping command within that onReceive() method while the CPU hasPARTIAL_WAKE_LOCK, so I was searching a way to manually sending ping to server but it seems the client doesn't expose any such method. Am I missing something? Or, what is the workaround here except publishing my own "ping message"? I want to avoid that because of: 
> 1. Larger overhead
> 2. We'll ensure that Android clients are subscriber only, may be with Mosquitto's ACL. They will not be allowed to publish messages.
> 
> Regards,
> Mehdi 
> _______________________________________________
> paho-dev mailing list
> paho-dev@xxxxxxxxxxx (mailto:paho-dev@xxxxxxxxxxx)
> http://dev.eclipse.org/mailman/listinfo/paho-dev





Back to the top