0

On my device using wifi network sometimes I have to refresh internet connection to receive notifications.I have set time_to_live = 5 to receive instant notifications only. It seems that connection of device with gcm servers is broken some times. But as soon as I refresh wifi internet, notifications start to come properly. This is strange and practically unreliable because I have to refresh internet connection again and again to receive notifications. Please help in this regard! Thanks in advance.

just_user
  • 11,769
  • 19
  • 90
  • 135
Saif
  • 397
  • 1
  • 9

1 Answers1

1

I have read about this same problem in Products Forum - Push notifications delayed, Hearbeat Interval not reliable. According to the old thread:

Android push notifications works through one TCP connection on the port 5228 between the phone and google servers. This connection is established when the phone connect to a network. All android push apps (gmail, whatsapp, hangouts, etc.) use Google Cloud Messaging (GCM) to send and receive push notifications thought that connection.

By definition a TCP connection does not have a timeout. But in the real world, wifi routers and mobile carriers have some rules to limit the number of opened tcp connections. So they usually close/kill what they think to be an inactive connection after some times that no packets are transmitted. For example my wifi router kill connections after 300 seconds (5 minutes) of inactivity (no packets on the tcp connection).

Then, it was given in this Google thread - Delay in getting GCM notification that this particular case is not a bug with GCM, rather it is an over-zealous router.

To fix it:

We found we could keep the connection alive with a ping every two minutes from the GCM server (which is free). There may be battery life implications for the device as I suspect the 15 minute timer that triggers the cooee is the same one you are supposed to align internal alarms with to minimize battery use.

Along with my searches, I also found this SO post - Do not receive GCM message while android device bein connected to WIFI which suggests upgrading to FCM as one that solved the issue and maybe it will work for you too.

Community
  • 1
  • 1
Teyam
  • 7,686
  • 3
  • 15
  • 22