45

Overview

I am sending messages back and forth between a client (Android phone) and a Server (Windows Server). Using a persistent connection over TCP, which protocol would be the best solution. I am looking at performance, scalability, size of messages, and battery life. The messages must arrive at the destination in order and can not be duplicates.

MQTT

This seems like the better solution, but there seems to be little examples of large implementation with lots of users. I am not sure if I can integrate this into the windows server, or if it would have to be another application or server running. Finally there seems to be a lack of information on it in general.

XMPP

This seems to have lots of implementation, examples, and even a book : ). However the main purpose seems to be for instant messaging clients and things like Google talk. Will this be an optimal solution to messaging between server and client. I know currently XMPP is mostly used in client to server to client architectures.

Please correct me if I am wrong and thanks in advance for any guidance.

Scott
  • 993
  • 3
  • 10
  • 28
  • Why did you specifically pick those two options? – dtb Aug 20 '11 at 05:28
  • 1
    From my Googling efforts they both seem to solve my original problem, push/pull over a persistent connection to a mobile device. They also both deal with xml messages which is most of the communication taking place. The MQTT caught my eye because it is meant to save on battery life (for the phone) and is meant for delivering messages over slow connections such as 3G. The XMPP seemed to be a solution used by many to handle messaging and it seems to be built pretty well for it. But I am open to suggestions – Scott Aug 20 '11 at 05:38
  • As a side note, one MQTT client thing to checkout, that is lightweight and portable can be found here https://github.com/wolfSSL/wolfMQTT .It would provide examples for quick testing of memory size and performance. – Sweetness Dec 08 '15 at 18:34

3 Answers3

69

It depends on what you are trying to do and what hardware you are running.

MQTT has very low keep-alive traffic. XMPP is a an IM protocol, and has a much, much higher overhead in handling presence messages between all the clients.

If you have a small memory footprint constraint, then having to handle the XML parser may make the use of XMPP impossible.

Keep in mind that MQTT stands for Message Queue Telemetry Transport, i.e., it is a transport protocol and does not define the message format at all - you will have to supply this; XMPP is an Instant Messaging protocol which carefully defines all the message formats and requires that all messages be in XML.

In addition to all this: MQTT is a publish subscribe protocol, XMPP is an instant messaging protocol that can be extended (using XEP-0060) to support publish subscribe. You need to consider this when you architect your system.

We are finding MQTT to be the quiet achiever. Your milage might be different.

It all depends ...

Track down the recent announcement by LinkedIn where they discuss their use of MQTT in their mobile app.

Cheers Mark

(BTW Andy was slightly off in his reference to us. We are at Centre for Educational Innovation & Technology (CEIT), The University of Queensland, Brisbane, Australia)

Mark Schulz
  • 1,070
  • 8
  • 11
  • 4
    I think you meant the Facebook announcement, not LinkedIn. The link is https://www.facebook.com/notes/facebook-engineering/building-facebook-messenger/10150259350998920 – ralight Aug 20 '11 at 18:59
  • Thanks for the response, I think the only problem I am having with MQTT right now is how to embed it into an existing c# server. It seems XMPP would just add extra data to the messages where MQTT would sit nicely on top of the TCP connection and send very little data. – Scott Aug 21 '11 at 03:20
  • 1
    If presence is not required for your solution, then you will not be dealing with Rosters and thus there will be no overhead due to presence messages. Although XMPP is used heavily for IM, it is just a real time comms protocol. Many of the extensions are IM specific, but many more are not. – Robin Feb 02 '15 at 20:34
13

I think that in short the MQTT advantages over XMPP are:

  • Throughput capacity: less overhead, more lightweight
  • Binary vs plain text
  • QoS in place (Fire-and-forget, At-least-once and Exactly-once)
  • Pub/Sub in place (XMPP requires extension XEP- 0060)
  • No need for an XML parser
Teixi
  • 1,077
  • 8
  • 21
  • 4
    While all of your points are correct, the one about pub/sub is misleading. Many XMPP servers support XEP-0060, so it is already 'in place'. You make it sound as if there is some extra work or something required. The bulk of capabilities in XMPP are defined in extensions, which are typically just application level rules on the basic messaging structures defined in the core. – Robin Jul 03 '15 at 18:55
7

I think you are probably correcting your assessment of XMPP in that it is a primarily chat-oriented protocol - it is also quite heavyweight and uses XML extensively making it verbose. I know that folks at CEIT at the Uni of Brisbane have specifically studied the differences and optimal uses for the two protocols. MQTT is very lightweight and low power - it has been used for telemetry and sensor applications for over 10 years and has been deployed on a very large scale by IBM and partners. Folks are now finding that a simple protocol like this is ideal for mobile development.

What exactly are you looking to achieve? The mqtt.org site aims to provide good links to content. There are also IRC channels and mailing lists about it. How can we help?

Andy Piper
  • 11,422
  • 2
  • 26
  • 49
  • Do you have a link to those studies performed at CEIT? I'm interested in reading more on this topic. – dtb Aug 20 '11 at 22:36
  • Thanks for the reply, as I said below the main problem if I choose MQTT is how would I embed it into a current written C# server. – Scott Aug 21 '11 at 03:22
  • @dtb the CEIT page is http://ceit.uq.edu.au/content/messaging-protocol-applications – Andy Piper Aug 22 '11 at 13:38
  • @Scott there are a couple of C# implementations of the MQTT protocol I believe - certainly a couple are linked from the mqtt.org Software page. I don't know how complete they are, though. – Andy Piper Aug 22 '11 at 13:38
  • FYI This link is broken. – Michel Feinstein Jun 16 '20 at 03:19
  • 1
    It’s nine years old... there are still some ways to check into the history, such as the Wayback Machine. – Andy Piper Jun 16 '20 at 09:25