TCP connections stalling / Gmail, Gtalk, WhatsApp issues [fix in place - testing]

ajax

Executive Member
Joined
Oct 29, 2003
Messages
5,605
When my Vodacom sim was in my phone and I left it lying there waiting for the hour of inactivity to arrive so I can test my gmail push....it would every now and again make that bzzz bzzz noise. With my Cell C sim in it tonight...I noticed nothing....dead radio silence...dood soos 'n mossie. This then also tells me that my Vodacom sim every now and again "refreshes" the connection or does something to keep it going. With Cell C sim it just goes dead and therefore it would be impossible for the C2DM push server to send notifications to my apps.

Sorry I know that sounds dof....but that is how I think of it. And the bzzz bzzz is the only way I know how to describe that sound a phone makes through sound speakers. Sure you guys know what I am talking about :)

Know what you mean. Dunno if it fully explains it though but the bzzz bzzz on my alarm clock/radios is more noticable when the phone is on a GSM 900 channel. It is less noticable when using a GSM 1800 channel and least when using UMTS 2100. Vodacom uses GSM 900 but Cell C doesn't. They may still have a few EGSM channels floating around somewhere. So if you're phone was on GSM only then that could explain why you didn't hear the bzzz bzzz when using the Cell C simcard. Maybe repeat the test with the phone as close as possible to the earphone wire.
 

Ockie

Resident Lead Bender
Joined
Feb 16, 2008
Messages
52,925
OK...doing the test now again with my Cell C 2Gig data sim. Just sent a test mail while phone was active...came through instantly. Going to try it again in 30 minutes of inactivity on the phone and if it still works wait a hour as I did the last time with my Voda sim. Will report here. Hold thumbs.
 

Hummercellc

Expert Member
Joined
Jan 6, 2008
Messages
3,451
Sounds like Skype on any of the networks.....

I have a galaxy S2 and use Cell C, No problems with Gtalk or Gmail on my phone?
 
Last edited:

Ockie

Resident Lead Bender
Joined
Feb 16, 2008
Messages
52,925
Ok. Testing is done finaly. Results:

Cell C 2Gig sim

Test mail while phone is active - received instantly
Test mail (after 30 minutes of inactivity) sent 18:02
Test mail received 18:26 (Fail)

Vodacom Prepaid Sim

Test mail while phone is active - received instantly
Test mail (after 30 minutes of inactivity) sent 19:31
Test mail received instantly (Pass) - going on to 1 hour inactivity test

Test mail (after 60 minutes of inactivity) sent 20:44
Test mail received instantly (Pass) -DONE
 

Base122

Well-Known Member
Joined
Aug 2, 2011
Messages
477
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?!! :D
 

Ockie

Resident Lead Bender
Joined
Feb 16, 2008
Messages
52,925

Eish...I cant remember what you said last night. Something something TCP IP goetters blah blah! :)

Thank you very much for digging in so thoroughly into this. I kinda followed what you saying and get the drift of it. It seems very technical and glad you did this investigation as I am sure Cell_C will find it very very handy and save them a lot of digging and figuring out what the hell is up with their network and ports and stuff :)

Tnx again. Lets see now what feedback he gives us after he discussed this with the network guru's. :)
 

ginggs

༼ つ ◕_◕ ༽つ
Super Moderator
Joined
Jun 26, 2006
Messages
12,151
Thanks Base122 for another detailed post.
...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.
Email is definitely store and forward, but I don't think Gtalk and Skype are. Gtalk usually won't allow you to send an IM to someone who is not online. I think this might be why my message to ocleroux was lost the other night, as far as my chat client was concerned, he was still online and available so the message was sent, but his connection had stalled and was unable to receive it. I have seen some Skype clients store undelivered IMs locally and then forward when the sender and the recipient are both online at the same time again (could be weeks or months later, with confusing results). I don't have WhatsApp (they don't have an N900 client :() but considering it is a paid-for service and is advertised as an SMS replacement I expect it would have store and forward.
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)
I doubt that, the chat/mail clients initiate the connection to the server, not the other way round.

the port 5228 "push" mechanism works as it should on Vodacom, but is broken on Cell C.
Just to be clear, you confirmed this using your two Android phones, one with a Cell-C SIM and one with a Vodacom SIM?
 
Last edited:

Base122

Well-Known Member
Joined
Aug 2, 2011
Messages
477
Just to be clear, you confirmed this using your two Android phones, one with a Cell-C SIM and one with a Vodacom SIM?

Correct. That is my test setup.
Each phone has its own gmail account sign on, so that I can test Gmail and Gtalk between them.
Whatsapp uses each phones cell number to identify my "two" users.
Can't comment on Skype as I do not use it. Are people also having problems with this on Cell C?

Take a look at this for a short explanation on how C2DM works:
http://android-developers.blogspot.com/2010/05/android-cloud-to-device-messaging.html

Both Gmail and Whatsapp work on the store and forward principle, as you mentioned.
Neither worry about whether the message recipient is online or not.

But, both seem to use this port 5228 C2DM to wake up the gmail or whatspp client app on your phone, which then causes that app to initiate a new connection to its respective server and check for a new message. So to the user it will look like a push, when in fact all it is doing is giving the client app a "tickle" (as described in the link) and forcing it to immediately "poll" its server in near real time.

Gtalk on the other hand, relies on the fact that both clients are online or connected to the chat server at the same time.
(Or so I thought)

Just did a test where both Gtalk clients show their "friend" online, but the test message I sent from the one to the other and vice versa never showed up.....until a couple of minutes later.... This implies some kind of store and forward system as well. Not sure why the delay. Will check that later again after I reboot both phones for a clean start. Interesting.

As for Whatsapp being marketed a replacement for SMS, yes it does store and forward, but without this C2DM push mechanism working properly there can be long delays between sending and receiving messages. (like SMS's sometimes)

True SMS apparently works via some other internal data channel on the cellular network (also store and forward), where Whatsapp relies solely on your data connection and can be affected by issues such as restrictions, data network problems, servers unavailable, etc.

I still think the problem is related to Cell C's inbound restriction on this port 5228. (But, hey I'm no network specialist!)
I have an idea they are not allowing the inbound "tickle" to reach your phone and wake up your gmail, gtalk and whatsapp clients accordingly.

Edit: Would be great to able to try all this on an a Cell C unrestricted APN (Here's hoping...) and see if network restrictions are indeed the problem .... ;)

Going to take a look at the Wifi issue now....
 
Last edited:

ginggs

༼ つ ◕_◕ ༽つ
Super Moderator
Joined
Jun 26, 2006
Messages
12,151
What happens if you try a Cell-C SIM card roaming on Vodacom? I'm not sure about Android, but most phones have the option of manual network operator selection.
 

Base122

Well-Known Member
Joined
Aug 2, 2011
Messages
477
What happens if you try a Cell-C SIM card roaming on Vodacom? I'm not sure about Android, but most phones have the option of manual network operator selection.

Gulp!! Roaming data charges.... OOB shark circling...:wtf:
Will try.
 

Ockie

Resident Lead Bender
Joined
Feb 16, 2008
Messages
52,925
What happens if you try a Cell-C SIM card roaming on Vodacom? I'm not sure about Android, but most phones have the option of manual network operator selection.

I have tried that. Did not work for me. :-( Will test it again now now to make doubly sure. :)
 

Ockie

Resident Lead Bender
Joined
Feb 16, 2008
Messages
52,925
Nope...roaming on Voda does not resolve it either.

Email sent: 12:17
Email received: 12:45

:-(
 

Ockie

Resident Lead Bender
Joined
Feb 16, 2008
Messages
52,925
So the problem's not with Cell-C then? :p

hehe. I would not say that. I think the reason for this is that even though you connect using a Vodacom tower when you roam, your connection eventually still goes through the Cell C routers and ports and billing systems etc etc. Vodacom is basically just providing the last mile whereas from there it gets handed over to the Cell C network and there you run into the same bloody port and ip problems.
 

ajax

Executive Member
Joined
Oct 29, 2003
Messages
5,605
Another interesting test may be to use a Virgin Mobile sim set firstly to use Cell C and secondly roaming on Vodacom.
 

ginggs

༼ つ ◕_◕ ༽つ
Super Moderator
Joined
Jun 26, 2006
Messages
12,151
I think the reason for this is that even though you connect using a Vodacom tower when you roam, your connection eventually still goes through the Cell C routers and ports and billing systems etc etc.
Are you sure about that? A traceroute should be able to confirm.
 

Ockie

Resident Lead Bender
Joined
Feb 16, 2008
Messages
52,925
Are you sure about that? A traceroute should be able to confirm.

Nope...not sure...hence why i said "I think" hehe. I am a noob when it comes to these things. It is just how I make sense of things in my head. :) What is a traceroute???
 

benitok

Senior Member
Joined
Jan 30, 2007
Messages
746
Are you sure about that? A traceroute should be able to confirm.

Even when you are not roaming and you are on Cell C, you would still connect to some Vodacom towers. (I've got an email from Cell C confirming this)
 
Top