Right!, this is going to get technical and heavy, so pull up a chair....and put that gum away!
Did quite a bit of testing around the gmail, gtalk and whatsapp "push notification" feature.
Here goes....
I used two android phones, HTC Desire HD (Cell C) and Vodafone 858 (Vodacom), running OS Monitor 1.1.8 showing internet connections on both as a test setup.
Both whatsapp and gmail make periodic connections to their respective servers, Softlayer Technologies and Google at certain intervals.
This allows both apps to check if there are any new whatsapp messages or gmail emails.
But these connections DO NOT remain active and disconnect after a period of time. (more on this later)
So as I said before, if both you and your friend have active server connections at the same time, your messages and emails will go through within seconds. But if one of you are not connected at the same time (you would never really know) the system becomes store and forward and will only send you the message or email, the next time your app connects or checks in. This mostly happens in the background, unless the user manually opens the apps and forces a refresh, or sends a new message or email. Of course your phone has to have an always on internet connection, background data allowed and Auto-Sync on.
So how does "push" notification work?
Very clever actually. It uses a feature called Google C2DM (cloud to device messaging), which relies on there being an active established connection to Google's servers on TCP port 5228.
Using OS Monitor, I noted that both phones kept a permanent port 5228 connection active all the time, sometimes called "Contacts Sync Adapter" or "Google Services Framework" or some other google type service. The important and critical thing is always port 5228.
So what actually happens, is that when the whatsapp or gmail server has a message for you, it sends an alert of sorts to you via your port 5228 connection. This in turn activates either whatsapp or gmail on your phone to wake up and make a connection to the whatsapp or gmail server and quickly retrieve the message. One can see this actually happen in OS Monitor network connections. The message is retrieved from the server to your phone and the connection remains active for a few minutes before disconnecting again. This disconnect is either done by your phone app or from the server side. (not quite sure) I don't think this disconnect is forced by the cellular operator at all, as it happens on both Vodacom and Cell C. (well almost, but not quite properly)
Gtalk on the other hand seems to send its messages directly through this port 5228 connection and does not seem to make a new network connection.
So how do you ensure you have this C2DM port 5228 active all the time?
Seems if you install Android market (and maybe other google services or apps) it will be installed and activated.
You also have to be logged in to google's servers somehow, like signed into your gmail account.
Without these two things being true, you will not have an active port 5228 connection and "push" notifications will not work for you.
.
.
.
Bio/smoke break....
So whats the problem here?
And why are Cell C customers complaining?
Well, the port 5228 "push" mechanism works as it should on Vodacom, but is broken on Cell C.
Even though the Cell C phone shows the port 5228 connection active, it never responds to the C2DM alert and then never "wakes up" whatsapp or gmail to display your new message or email. Something seems to interfere with port 5228, which in turn impacts on Gtalk as well. This is why you are not getting your messages in near real time and thinking things are broken (true on the Cell C network)
On Cell C, many outbound connections seem to remain "hung" in the CLOSE_WAIT state, as if something is not allowing these connections to close properly. On Vodacom, connections close properly and neatly as they should and the port 5228 responds to C2Dm alerts as it should.
I suspect this may be related to Cell C's extreme restrictions on their IP connections.
My suggestion is for the Cell C technical network guru's to look at the following:
Gtalk, whatsapp and Gmail all make use of TCP ports 443, 5222, 5228 and possibly others.
If you are not allowing an inbound message on port 5228 (not sure if only TCP or maybe UDP as well), then the "push" notifications will not work. Also check restrictions on ports 443, 5222 and try and find out why connections using these ports are "hanging" in the CLOSE_WAIT state.
Hopefully all this will be useful in resolving this issue of broken "push" notifications on the Cell C network.
I have read on some other thread about similar problems on the Vodacom network at some point, but these may be resolved already?
Perhaps the Cell C network specialists can chat to the Vodacom specialists to find out about restrictions on these particular ports and how this impacts the "push" feature of Gtalk, Gmail and whatsapp.
Note: If you are on a Wifi connection and having problems with "push", you may have to set up NAT or port forwarding to your phones IP address for 5222, 5228, 443 (Will experiment with this some other time)
Will PM this story to CELL_C as well.
Oi! You back there, what did I say last night?!!
