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).What happens is that, when I don't have push notifications for 5 minutes, the router kill the connection because is inactive and android is not able (since the router didn't sent any ack to the phone) to intercept that the connection has been closed because of a tcp idle timeout rule. From that moment the GCM connection is a dead connection and no push notifications are received until the connection is re-established (switch wifi/mobile connection off and on, or an heartbeat is sent, see below).Android have a mechanism to send a little network packet (called heartbeat) every x minutes to avoid the tcp connection timeout and check if the connection is alive; that is a wide common and working practice. If the connection is not alive, the GCM connection is re-established and previously notifications and new one come again.What is the problem? The problem is that the heartbeat is sent with the following intervals:- every 28 minutes on mobile connection, 2g/3g/4g; - every 15 minutes on wifi;(You can see those values by dialing on the phone *#*#8255#*#* (with new play services you can dial *#*#426#*#* if previous don't work) . Those values are updated remotely through Google Checking mechanism, so if google want, they can easily update those values and all android devices will have new values in about 24 hours.)Those are to much high values for most of the users in the world. Mobile carriers close inactive tcp connections much sooner, same as wifi routers (most wifi routers kill inactive connections after 5 minutes!). This cause delayed push notifications!Please implement a dynamic mechanism to set the right heartbeat interval value depending on the user connection, or set a low heartbeat interval like 2 minutes! I did a lot of test by changing the heartbeat intervals, battery is not impacted to much at all (if you have root search Push Notifications Fixer on play store). Lot android users think that push notifications are broken because of this problem, please take care of this, short the heartbeat interval. It is so annoying! This problem exists since the introduction of push notifications, android 2.2, till as currently android kitkat 4.4.2.Note that not all users are affected by this, only users with some routers or some carriers with strict policy to kill inactive tcp connections are affected. All carriers/routers kill inactive connections after some time, the problem are the carriers/routers that kills connection after so short time.Also some of you may have a different problem, like wifi/3g completely drop while the screen is off, that's an other problem.As last note even iPhone users have push notifications delayed in some cases as well, so people don't complain about that.Because of this issue, some apps developer start to use their own separated connection to mitigate, or sometimes make worse, the problem (see whatsapp, they have a connection on the port 5222 that go on timeout as well..).tag: push notification delay, push notifications delay, push notification delayed
Thursday, 17 July 2014
Info on Why Push Notification gets delayed
Subscribe to:
Post Comments (Atom)
Pass a HashMap from Angular Client to Spring boot API
This example is for the case where fileData is very huge and in json format let map = new Map<string, string>() map.set(this.ge...
-
package com.example.spinnerhint; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.app.Activi...
-
I faced this issue while implementing custom image button , here in xml following attribute is not supported android:background="?...
-
best link for android timers http://www.fampennings.nl/maarten/android/04timers/index.htm orientation best link Orientation Change h...
No comments:
Post a Comment