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

Hello Mehdi. Welcome to the community discussions for Paho. The component committers are on holiday this week so there may be  some delay in getting you an answer. In the meantime, there may be someone else on the mailing list who has an answer.

I am quite interested in following the progress of your application of MQTT on Android.


From:        "Dr. Mehdi Hasan Khan" <mhasan@xxxxxxxxxxxxxxxxx>
To:        paho-dev <paho-dev@xxxxxxxxxxx>
Date:        04/08/2012 03:17 PM
Subject:        [paho-dev] Manually sending ping using Paho MQTT client
Sent by:        paho-dev-bounces@xxxxxxxxxxx


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."

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.


paho-dev mailing list

Back to the top