Google Cloud Messaging - messages sometimes not received until network state changed

后端 未结 5 1809
我寻月下人不归
我寻月下人不归 2020-11-28 04:40

While working on a little project that integrates with GCM, I\'ve stumbled across a bit of a strange issue.

Some times when I start watching the log to see if messag

5条回答
  •  感动是毒
    2020-11-28 05:31

    There are many causes for GCM message delays. If message start to arrive after you changed network state, or switched on/off airplane mode - the most likely cause is a network that closes the connection without sending FIN/RST.

    GCM maintains a long-lived connection - and reconnects if it knows the connection was broken. A router/AP/NAT is supposed to send a FIN or RST to terminate the TCP connection - so GCM and servers will know the connection is dead.

    However a number of routers and mobile operators don't do this, and then GCM needs to rely on the heartbeat, ~15 min on Wifi, more on mobile. There is a trade-off between battery life/network use and heartbeat frequency.

提交回复
热议问题