且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

GCM连接服务器如何将消息发送到Android设备?

更新时间:2023-01-17 10:55:27


  • (没有Google Play服务的情况下无GCM)
  • 设备通过端口5228上的 TCP连接到Google Play服务
  • 设备每隔28分钟在移动设备上发送一个心跳数据包至Google Play服务,并在WiFi上每15分钟发送一次 如果设备网络状态发生变化,该设备必须重新建立与Google Play服务的TCP连接,该连接显然可能导致问题

  • 您可以检查连接状态,心跳间隔,co连接地址和端口等。在设备上拨号 *#*#426#*#*


您可以在Google产品论坛的这篇文章中找到更多信息


I was reading about Google Cloud Messaging(GCM). The push notifications received by GCM Connection Servers are sent to GCM enabled Android device. I assume that internally it uses device Id(and then resolving to IP from MAC using ARP protocol) to send the push notifications. Which protocol GCM uses internally to deliver notifcations? If it is TCP/IP then how it resolves IP of the device(which is not unique given that a user switches wifi networks and mobiles data).

Can anyone help me understand the communication from GCM to the client?

  • GCM works through Google Play Services (no GCM without Google Play Services)
  • Devices connect to Google Play Services through TCP on port 5228 (443 as fallback)
  • Device sends a heartbeat packet to Google Play Services every 28 minutes on mobile and 15 minutes on wifi
  • If device network state changes, the device has to reestablish a TCP connection to Google Play Services, which apparently can lead to problems
  • You can check the connection state, heartbeat interval, connection address and port, etc. dialing *#*#426#*#* on a device

You can find some more information in this post on Google Product Forums.