Android C2DM port number choice
Asked Answered
S

2

13

I noticed that the Google C2DM (push) tcp connection uses port 5228. I also know that some firewalls block ports other than 80 443 (because of htttp and https), which causes lots of users to complain that they can't use the Market app or GTalk on their phones using their company wifi for example.

Now my question is: why didn't Google choose port 443 or 80 for their persistent tcp connection?

Simpleminded answered 24/5, 2011 at 6:1 Comment(0)
S
12

There are a few reasons I can think of that Google may have chosen to use 5228 instead of 80 or 443.

Firstly, in most (but definitely not all) cases, 5228 should not be a problem (i.e. blocked) because push notifications are largely used when devices are on the go. This means they are using cell phone data connections that do not block this port and are not firewalled.

Secondly, in the case of environments where there might be a firewall (i.e. with WiFi inside a corporation), it is also likely that http traffic is proxied or controlled in some fashion. C2DM does not rely on a standard HTTP protocol and is expected to be a long-lived connection. This means that running it on 80/443 might cause issues in these environments.

Thirdly, these services likely were using 5228 prior to the release of C2DM and there was no clear reason to change it.

Based on my experience, I think it would have been ideal if they used 5228 as a default, and attempted to fall-back to 443 in other cases (as there are definitely many scenarios where 443 would work when 5228 wouldn't). At least in the case of 443, modification of data is less-likely than if on port 80 because the protocol would normally be encrypted. However, it is still possible the connection would be prematurely terminated on 443. However, this risk exists in any network environment, and there would be no downfall in trying.

And on separate note, it is likely that enabling C2DM on 443 would have been more difficult than it seems for Google because their distributed front-end servers likely know how to specifically handle 80/443 traffic as HTTP and would require significant re-working to handle C2DM.

Schwing answered 18/8, 2011 at 12:21 Comment(4)
very nice explanation! I was just wondering about how to decide whether to fall back to 443 or not? I'm saying this because there might be other conditions, like no internet connection, that would be indistinguishable from wifi blocking some port for example. I haven't looked into this, but it seems like the correct thing to do. Thank you!Simpleminded
do you think carriers throttle / cut short connections based solely on port number? or do they whitelist for example google ip's, in which case the port number choice doesn't matter?Simpleminded
It is possible they throttle for certain ports - but I doubt that is the case for port 80 or port 443, or any arbitrary port. More likely it is for ports used commonly for file sharing (but in most cases these ports are random, and it is more likely some type of traffic sniffing would be required to do shaping). I doubt that traffic to Google is given any special treatment.Schwing
what about keep alive timeouts? do you have any pointers on what values are safe?Simpleminded
V
1

I suspect as they wanted to get the standard ports for something else and this way they can easily monitor traffic levels of C2DM traffic.

They are not alone and Apple do exactly the same for their push implementation.

Vedavedalia answered 18/8, 2011 at 7:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.