【问题标题】:Does push notification cause a continuous polling on server?推送通知是否会导致服务器上的连续轮询?
【发布时间】:2016-10-05 11:15:55
【问题描述】:

我正在使用 Google 频道从服务器推送通知。它工作正常,但是当我打开调试器窗口时,我可以看到很多轮询请求正在发送到服务器。

这是推送通知的工作方式吗?如果是,那它有什么用呢?

var token ="<%token%>";// This will creaete unique identifier(some id created by google api + ur key)

   channel = new goog.appengine.Channel(token);    
       socket = channel.open();    

   socket.onopen = function() {

     $('#messages').append('<p>Connected!</p>'); 

   };

谢谢。

【问题讨论】:

    标签: push-notification google-cloud-messaging polling firebase-cloud-messaging server-push


    【解决方案1】:

    GCM 不这样做。会在它的流程上参考official docs。

    生命周期流

    • 发送和接收下游消息。
      • 发送消息。应用服务器向客户端应用发送消息:
        1. 应用服务器向 GCM 连接服务器发送消息。
        2. 如果设备离线,GCM 连接服务器会排队并存储消息。
        3. 设备在线时,GCM 连接服务器向设备发送消息。
        4. 在设备上,客户端应用根据平台特定的实现接收消息。有关详细信息,请参阅特定于平台的文档。
      • 接收消息。客户端应用从 GCM 连接服务器接收消息。

    在最近的 I/O 2016 上也宣布,GCM 的继任者现在是Firebase Cloud Messaging,它不仅具有推送通知服务,而且还具有其他免费功能(例如 Analytics)。

    总的来说,使用 GCM(或 FCM)是一种比轮询更简单的方法。它处理您发送的消息和其他一些消息的排队。


    我的部分回答 here。还包括为什么Polling 在发送推送通知时并不理想。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-22
      相关资源
      最近更新 更多