简体   繁体   中英

Receive Android GCM messages so slow?

Google Cloud Messaging (Push message) problem.
I have two smartphones(HTC Sensation XE, Desire HD) and a tablet(Samsung Galaxy Note 10.1 Wifi).
Sometimes I need to wait for almost 15 minutes to receive the GCM push messages. Sometimes I receive the GCM push messages immediately(within 30 secs).

Below is my test result:
The left side is server send time, while the right side is client mobile receive time.
All the test results are under Wifi connected environment.
==========================
HD 23:10:18, 23:24:XX

XE 23:11:21, 23:22:44

Note 23:10:20, 23:14:54

==========================
HD 00:08:12, 00:08:27

XE 00:07:55, 00:07:58

Note 00:08:04, 00:13:35

==========================
HD 00:40:21, 00:55:22

XE 00:39:56, 00:40:14

Note 00:40:13, 00:40:59

Thanks!!

GCM uses throttling when there's excessive use, see the following document for more details:

http://developer.android.com/google/gcm/adv.html#throttling

Please read my answer here:

Google Cloud Messaging - messages either received instantly or with long delay

It's basically a tcp timeout problem

You can manually trigger the heartbeat to keep the connection alive by the following code. Some network routers will automatically kill the idle socket connections if it is idle for a particular time period (sometimes 5 minutes). Execute the code in every 5 minute so that the connection will be re-established if it is closed. But, obviously reducing the interval will consume bit more battery (I don't know how much it is relevant here because nowadays the smart phones come up with high mAh battery).

getApplicationContext().sendBroadcast(new Intent("com.google.android.intent.action.GTALK_HEARTBEAT"));
getApplicationContext().sendBroadcast(new Intent("com.google.android.intent.action.MCS_HEARTBEAT"));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM