I have a large scale project with hundreds of devices out in the field that I communicate with using GCM. Recently I've been experiencing a strange issue where many of these devices have stopped responding to my GCM messages. A couple things to note:
Sending my payload to Google's GCM servers still returns a proper 200 response.
The GCM keys for these devices have been verified to be correct/active.
The device will start receiving GCM messages if I move the device to a different network/subnet.
The device will start receiving GCM messages if I change its IP address on the same network.
The device will start receiving GCM messages with its initial IP address if I clear data of the Google Playservices package and restart my application.
It seems as if the socket for GCM has gotten stuck in a disconnected state and does not reconnect. These devices are typically connected via wifi which does sometimes drop, however... This past weekend, over 100 of these devices stopped responded so that leads me to believe some sort of TTL has expired and a refresh never happened.
Has anyone experienced anything like this before, or have any thoughts or suggestions about this?
Related
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.
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.
I have an Android app capable of receiving two different types of Push messages. Our backend server, depending on its business rules generates these messages with appropriate Payload, no collapse keys (do not collapse) but different TTL ( first message lives only for an hour and other for 24 hour).
Everything works fine when the Android device is connected to a network.
However, when the device is not connected to the internet, and if it happens to receive messages of both types, when the device is brought online it only seems to receive message with longer TTL.
Can someone share insight to what is going on here?
I'm assuming that you're connecting the device to internet after TTL (time to live) has elapsed.
In that case, if your device doesn't come online for an hour, GCM will discard that message, which is exactly what is happening in your case.
Is your first message getting discarded even before TTL elapses and you get the device online?
I successfully integrated my app for receiving push notification using GCM. Its working correctly, I just saw a strange behavior while receiving push notification on one of my android set which is using my wifi network, in the same time others whose are using EDGE or 3G network are receiving notifications correctly. When I try to switch off and switch on the wifi, it receives the pending notification.
I tried opening the ports which normally used by GCM i.e 5228,5229 and 5230 in my router's firewall however with no success.
NB: After seeing this, I tried to configure the app for Parse API and its working as same as GCM so I think it depends upon the network packet receiving or something.
I believe, what you're facing is a known issue about TCP connection between GCM servers and your handset is timing out because of inactivity. Network devices (like your Wi-Fi router, your ISP hardware, etc.) between your handset and GCM servers could kill the TCP connection if no packets are sent every now and then.
There are some workarounds for this which you might try. For example, there are apps on Google Play that modify the default Android behavior and make it update this connection more often, increasing chances that it will not timeout. You could try them and see if it fixes the problem for you.
I am trying to use GCM to try and send messages to my application even when the device is not connected to the internet. I know that GCM usually waits till the device has internet and then sends it the message. However, when I test it with my app by disabling WiFi, sending a push message and then enabling WiFi I do not see a message being received. I am following the exact example from this site. Since I am using an IntentService and BroadcastReceiver I figured it would handle the case. Do I have to make any other changes to make it work while the device has no internet? Since
I have implemented chat in my project and using GCM for it.In this i have came across the strange issue.
I have do following steps for it.
Send chat message to server.
Server fetches reg key of device and send push message to GCM server.
Now on other device in which i am receiving push message i tried waiting for the push message for a long time.
But i did not receive the push message.
Now when i turn my wifi off and on it again or switch from 3g to wifi or vice-versa, i get all push messages at once.
I have read GCM docs and i also have seen these two questions in Stackoverflow.
Google Cloud Messaging - messages sometimes not received until network state changed
Device stops receiving GCM pushes until network is switched
I have also referred a google groups question regarding this issue
Problem in getting messages on device using GCM.
But i didn't get any solution till now.
I am using Asp.net at the server side.
Any help or suggestion is appreciated.