Google Cloud Messaging - messages either received instantly or with long delay

前端 未结 1 1969
星月不相逢
星月不相逢 2020-11-29 09:10

I am using Google cloud messaging in my final year project for college. Everything works okay but I have been having a bit of trouble with GCM. Pretty regularly, messages ar

相关标签:
1条回答
  • 2020-11-29 09:28

    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.

    EDIT (2014/01/08): currently Google updated the heartbeat intervals to 8 minutes for wifi and mobile connections. Tha'ts a remote change which impact all android devices 2.2+ This is a good improvment to avoid the tcp push connection timeout. Still, if a wifi router kill inactive connections after 5 minutes, you will have a 3 (8-5) minutes delay in push notifications (if you hadn't other notifications that keep alive the connection)

    EDIT (2016/03/06): now google seems to be testing my 2 years ago feedback, to have a dynamic mechanism to determinate the right heartbeat interval depending from the network. Currently seems a staged rollout and only for wifi as for what I know. So based on the wifi SSID the algorithm determine the right heartbeat interval for the specific wifi with a sort of stepwise refinement. This sound very good! This is a remote change which impact every android phone that has Google Play Services.

    0 讨论(0)
提交回复
热议问题