17

I've read the documentation https://developer.android.com/google/gcm/index.html

and the only difference I can see is that a CCS (XMPP) based server allows bi-directional communication directly between an android device and the GCM server.

Are there any other reasons why you would choose CCS (XMPP) over HTTP or vice versa?

Eran
  • 387,369
  • 54
  • 702
  • 768
Bachalo
  • 6,965
  • 27
  • 95
  • 189

5 Answers5

19

CCS (XMPP) is asynchronous, which means it should be faster than HTTP. It also uses the existing GCM connection on the device to send messages from your app to your server (which saves battery, since you don't have to open your own connection to your server).

On the other hand, HTTP is much simpler to code, so unless you need the bi-directional functionality or you need to send messages in a very high speed, I'd stick with HTTP.

Eran
  • 387,369
  • 54
  • 702
  • 768
  • 1
    "CCS (XMPP) is asynchronous, which means it should be faster than HTTP": Shouldnt a simple async ajax call be similar? Also at any given point there is a throttle of 1000 msgs... so if you have many users communicating ccs should be an issue. – user1517108 Mar 11 '14 at 17:12
5

You can broadcast a message to 1000 devices at a time with a single http call to gcm. For broadcasting http is better than CCS.

guy_fawkes
  • 947
  • 8
  • 31
  • but how will you brooadcast to clients thru http? unless the clients are pinging the server for a broadcast. – user1517108 Mar 11 '14 at 17:14
  • You send a http post request to gcm server. It will broadcast to devices. Gcm server is the intermediate connection between our server and mobile devices. – guy_fawkes Mar 11 '14 at 17:24
2

unfortunately google cloud platform will disable the XMPP API after a year https://cloud.google.com/appengine/docs/deprecations/xmpp

I'd choose XMPP to save devices battery cause its one of the big concern nowadays!

Tamer Saleh
  • 473
  • 9
  • 21
1

XMPP messaging differs from HTTP messaging in the following ways:

Upstream/Downstream messages

  • HTTP: Downstream only, cloud-to-device.
  • XMPP: Upstream and downstream (device-to-cloud, cloud-to-device).

Messaging (synchronous or asynchronous)

  • HTTP: Synchronous. App servers send messages as HTTP POST requests and wait for a response. This mechanism is synchronous and blocks the sender from sending another message until the response is received.
  • XMPP: Asynchronous. App servers send/receive messages to/from all their devices at full line speed over persistent XMPP connections. The XMPP connection server sends acknowledgment or failure notifications (in the form of special ACK and NACK JSON-encoded XMPP messages) asynchronously.

JSON

  • HTTP: JSON messages sent as HTTP POST.
  • XMPP: JSON messages encapsulated in XMPP messages.

Plain Text

  • HTTP: Plain Text messages sent as HTTP POST.
  • XMPP: Not supported.

Multicast downstream send to multiple registration tokens.

  • HTTP: Supported in JSON message format.
  • XMPP: Not supported.
Mike Yang
  • 2,581
  • 3
  • 24
  • 27
0

From Google docs :

You can continue to use the HTTP request mechanism to send messages to GCM servers, side-by-side with CCS which uses XMPP. Some of the benefits of CCS include:

The asynchronous nature of XMPP allows you to send more messages with fewer resources.

Communication is bidirectional—not only can your server send messages to the device, but the device can send messages back to your server.

The device can send messages back using the same connection used for receiving, thereby improving battery life.