1

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).
Is it normal? Or just because I'm under Wifi connected?
If it is normal, are there any other services like "long-polling" I can use for retrieving messages from server?
I'm currently using GCM+Polling(AlarmManager) to retrieve messages from remote server.
Any suggestions or better ideas?

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!!

Raghav Sood
  • 81,899
  • 22
  • 187
  • 195
Cheng
  • 47
  • 2
  • 6
  • Have you tried setting the `time_to_live` parameters to 0? As outlined in the docs it will work hardest to send asap: https://developer.android.com/google/gcm/adv.html#ttl – Sauron Dec 11 '14 at 00:48

3 Answers3

0

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

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

soren.qvist
  • 7,376
  • 14
  • 62
  • 91
0

Please read my answer here:

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

It's basically a tcp timeout problem

Community
  • 1
  • 1
andQlimax
  • 778
  • 10
  • 24
0

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"));
Visruth
  • 3,430
  • 35
  • 48