GCM XMPP CCS vs MQTT - android

We have a requirement forMachine to Machine communication via our servers.
We initially planned to use MQTT+Rabbit MQ adapter to queue up published messages from clients, process the messages in server and publish it back to other set of subscribers.
With GCM supporting upstream messages via XMPP CCS, the same could be achieved through GCM itself, Since its GCM we dont need to worry about maintaining persistent tcp connection with our servers, and it reduces effort both in server and client side.
Now What are all the design aspects and technology limits should be considered in choosing MQTT with GCM?

GCM supports HTTP and XMPP but not MQTT
This article reflects some of the pros/cons on MQTT vs GCM with XMPP
http://ollieparsley.com/2013/05/20/using-mqtt-as-a-gcm-replacement-for-android-push-notifications/
But at the end depending on your specific need you should implement two test clients and see wich one is more efficient on battery usage and message reliability.

Related

Do XMPP Servers (Openfire) require implementations?

Do XMPP Servers such as Openfire require implementation of their own in order to handle messages. Do I need a web language such as PHP in order to handle messages with Openfire?
Because according to posts such as this How to make Chat Application in Android Using XMPP and GCM, I do not need to write PHP scripts in order to handle messages, Openfire (it being a XMPP server) will do all the heavy lifting. So when creating a messaging program is the only thing I need to worry about the client side code?
I've also run into contradictory information that I hope someone can clarify on. It was to my knowledge that one needed to use a XMPP server along side GCM; as GCM is not reliable in delivering messages by itself and requires an XMPP server to fully be reliable. Is this true, the above link suggests that it isn't, but according to this it is https://www.youtube.com/watch?v=5wXGcu9H91s
Some clarification would be great, thanks.
GCM allows you to use both HTTP and XMPP to send messages down from your application server through GCM to your devices.
Only with XMPP though can you send messages from your device through GCM to your server. This allows your device to send acknowledgment messages back up to your server. This does not necessarily make GCM more reliable but it does allow you to have a better audit of what messages were actually received by devices.
Openfire is a server that supports XMPP so you will still have to implement the protocol maybe using Smack.
Note that you could skip GCM and have a connection directly between your app and your XMPP server, however this is not recommended since your app would have to be constantly connected to your server which would be very hard on the battery of the device. This is where GCM comes in, allowing your app to receive messages even when it is in the background but still being kind to the battery of the device.

Android Chat functionality, Choosing GCM implementation over HTTP or XMMP

we have already implemented GCM over HTTP for our chat functionality, but after reading GCM XMPP xmpp document and google states below benefits offered by xmpp
Benefits :-
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.
we choose HTTP, since we are comfortable in developing using http rather than XMPP. but my concern is, will XMPP provides long term solution for our chat functionality?.
And i am not getting first two points, fewer resources (what exactly it is, when compared to HTTP), secondly, bi-directional messages, i see this can be achieved in HTTP either ,my flow diagram for http flow
i understand in http we need to create new connection when ever we need to invoke backend, so XMPP has advantage here. I would like to know is HTTP is right choice for chat functionality? for longer run..
XMPP should be used over HTTP for continuous communication.
XMPP supports upstream messaging, with HTTP your client (phone) has to make an HTTP call to your app server, you cannot send an upstream message to GCM without XMPP.
XMPP makes fewer connections so overhead (battery, data etc) is much less than with HTTP.

How Can An App Communicate With a Server and reflect updates immediatly?

hi this is just for knowledge. i will try to explain as much as i can what is my question.
Usually i call on an Async Service every amount of time i.e updates on the server part for example are not reflected as soon as they change. whatsapp for example reflects the updates almost instantly. for example when a user is typing, it shows to the other user that he is typing.
In short what protocols do they use and how do they use it.
thank you.
What protocols do they use?
Application like Whats app,G-talk ,facebook etc they uses XMPP protocol for IM services.
What is XMPP?
The Extensible Messaging and Presence Protocol (XMPP) is an open
technology for real-time communication, using the Extensible Markup
Language (XML) as the base format for exchanging information. In
essence, XMPP provides a way to send small pieces of XML from one
entity to another in close to real time
As per latest version of specifications XMPP provides below services
Channel encryption [RFC3920]
Authentication [RFC3920]
Presence [RFC3921]
Contact lists [RFC3921]
One-to-one messaging [RFC3920]
Multi-party messaging [XEP-0045]
Notifications [XEP-0060]
Service discovery [XEP-0030]
Capabilities advertisement [XEP-0115]
Structured data forms [XEP-0004]
Workflow management [XEP-0050]
Peer-to-peer media sessions [XEP-0166]
This are the core services available in XMPP
Below are some Applications where XMPP can be used
Instant messaging
Groupchat
Gaming
Systems control
Geolocation
Middleware and cloud computing
Data syndication
Voice over IP (VoIP)
Identity services
Like HTTP XMPP also require server-client implementation
Below are some popular XMPP servers
Ejabberd
Openfire
Prosody
Tigase
You can find more information on xmpp server on this link
Different platform has their different XMPP client library you can more information on this link
If you want to implement XMPP client for android then you can use Smack 4.1 ,it is an open source XMPP client library written in java.
I have tried to list down basic feature of XMPP here but if you getting started with xmpp ,then there are lost of things to learn , free to ask any doubt regarding XMPP I will try my best .
Thank you
Note::
for the user who are still using aSmack should Upgrade to Smack 4.1 as aSmack has been deprecated!!
aSmack Deprecation Notice
aSmack to Smack Upgrade guide
You could implement the Google Cloud Messaging (GCM) service, as the GCM site says:
Google Cloud Messaging (GCM) for Android is a service that allows you
to send data from your server to your users' Android-powered device,
and also to receive messages from devices on the same connection...
This way you can inform from one client a status change, the backend then send the propper message to the desired clients and finally those clients app updates the status.
https://developer.android.com/google/gcm/index.html

What is the primary usage of upstream messaging in GCM Cloud Connection Server?

What is the usage of Cloud Connection Server that was announced at Google IO 2013?
I'm interested to know whether I can use the upstream messaging feature to send specific messages to GCM server. For example, can I send a command to delete a GCM notification that is stored on the GCM server? Or is it only used to send custom messages? If so, why do we need it at all?
According to the docs, there is no such feature to delete messages from the GCM server.
The upstream feature serves only for delivering messages from the device to your 3rd-party server. The advantages of using device to cloud messaging instead of establishing your own connection between your app and your server is improving battery life. It's also supposed to be faster than the regular GCM (since it's asynchronous).
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 the server send messages to the device, but the device can send messages back to the server.
You can send messages back using the same connection used for receiving, thereby improving battery life.

Client(android) receive messages from server(java)

I am trying to create a chat application. The communication is based on RESTful web services(Jersey). The client communicates with the server sending HTTP requests. My problem is how to send messages from server to client without the client send a request first. I read about C2DM notifications, I suppose using this way, when the client receives the notification from the server then (the client) has to send a request to the server in order to receive the data. I also was thinking about using sockets but I don't know if it is possible as I am using Rest. I mean in the server side can I also use sockets(sockets run in lower level) with the REST code? The only thing I have though that could work using sockets is to create another server with socket(two servers RESTful and socket), but is this a good solution? Also could I put some server code in the client side and some client code in the server side. Would it be correct and effective? What do you think? Which solution would be the best?
C2DM has been officially deprecated as of June 26, 2012 by google. Existing C2DM developers are encouraged to migrate to the new version of C2DM, called Google Cloud Messaging for Android (GCM).
Check out this link for more info
http://developer.android.com/guide/google/gcm/index.html
The scenario you describe sounds ideal for C2DM. If you build your own sockets set up you will drain battery and CPU resources doing something the phone is already doing - maintaining an open socket to receive messages.
C2DM is relatively straightforward to set up, and in my experience is pretty reliable.
This is the best tutorial I have seen on it:
http://www.vogella.de/articles/AndroidCloudToDeviceMessaging/article.html
But you also need to read the official docs:
http://code.google.com/android/c2dm/
Your server-side code will need to send an HTTP request to the C2DM servers to send a message to a device. To tell it where to send the message, your server needs to specify the Registration ID (which represents your app running on one specific device) and so when your app sets up on the Android device, it registers with C2DM, and then needs to send its C2DM Registration ID to your server to be stored, ready to be used to send messages to.

Categories

Resources