I work with GCM in my application, and I have a problem.
Most of the time I get the messages right away, but sometimes the messages come after 5 minutes, one after another, like they got stuck on the way. Is this normal?
I work with GCM in my application, and I have a problem.
Most of the time I get the messages right away, but sometimes the messages come after 5 minutes, one after another, like they got stuck on the way. Is this normal?
The GCM framework part on the client phone use a TCP connection on the port 5228. This connection its used for push notifications, but as every tcp connection it can go on timeout with some routers/carriers that apply strict policies to kill inactive tcp connections (tcp idle timeout).
Most wifi routers kills inactive connections after 5 minutes for example, like mine.
The GCM framework use a keep-alive mechanism to send an heartbeat network packet every 15 minutes on wifi and every 28 minutes on 3G. This keep-alive is not always reliable for all users.
I opened the issue to google here: https://productforums.google.com/forum/#!category-topic/nexus/connecting-to-networks-and-devices/fslYqYrULto They agree there is currently an issue.
I've yet to notice that in my extremely limited testing so far, but from my understanding of the documentation, that doesn't sound terribly surprising:
GCM will usually deliver messages immediately after they are sent. However, this might not always be possible. For example, the device could be turned off, offline, or otherwise unavailable. In other cases, the sender itself might request that messages not be delivered until the device becomes active by using the delay_while_idle flag. Finally, GCM might intentionally delay messages to prevent an application from consuming excessive resources and negatively impacting battery life.
Between this and language throughout the rest of the documentation, what you've described sounds like exactly what I'd expect. There's no guarantee of immediate delivery; you'll usually have messages delivered right away, but sometimes you won't.
I am finding the same thing as the original poster. It seems to take up to 5 minutes to "wake up" and then it deals with the messages very quickly.
My app is handling text items in a conversation with a deaf person. The caller initiates the conversation, and the deaf person responds by phone. The delay occurs only in the first step, the new message "out of the blue". Once it's done the first one for that (application, device, system-Id?) the others come through very quickly, almost instantaneously.