Friday, October 11, 2013


What is XMPP?
- XMPP is communication protocol for message-oriented middleware based on XML.
Originally called Jabber, developed for instant messaging, presence info and contact list maintenance.
XMPP specs published in RFC 6120/21/22.

  • RFC 6120: XMPP Core
  • RFC 6121: XMPP IM
  • RFC 6122: XMPP Address Format


  • Mature, Open Standards based technology
  • Secure (SASL and TLS)
  • Extensible – Several extensions exist today ( 


  • Binary data transfer (e.g. file transfer) is inefficient (as it requires converting to Base64 encoded form).

Core includes:
  • XML streaming layer
  • Security: SASL and TLS
  • Presence: Built-in information about network availability
  • Rosters: Presence-enabled contact lists
XMPP defines 2 fundamental terms with respect to messaging:
  • Stream – Open XML envelope sent before more XML elements are exchanged between two entities.
  • Stanza – XML elements exchanged between 2 entities. 3 types:
    • Presence
    • Message
    • IQ – information or query
Client sends:
xml version="1.0"?>
<stream:stream to="" xmlns="jabber:client" xmlns:stream="" version="1.0">
Server acknowledges by sending:
 <stream:stream from="" id="someid" xmlns="jabber:client" xmlns:stream="" version="1.0">
... encryption, authentication, and resource binding ...
Client sends message:
xml:lang="en"> Art thou not Romeo, and a Montague?
Server forwards message to client:
xml:lang="en"> Neither, fair saint, if either thee dislike.
Client closes its stream/session:
Server closes its session:

Message – to/from = Jabber IDs. 
Wherefore art thou, Romeo?
IQ – Info/Query. 

  • Get/Set
  • Result
  • Error
  • Roster - Rosters are stored on the server so that the XMPP client may retrieve the same each time the user logs in. Rosters are a type of IQ Stanza. Example showing IQ message to request for roster.

Presence – the presence info of a user is broadcasted from server to all users in roster list of that user. This works using the PubSub messaging.

Bi-directional streams Over Synchronous HTTP (BOSH)

  • It is a long-lived 2 way communication over HTTP.
    • Significantly more bandwidth efficient over http (compared to other technologies – such as AJAX)
    • Applications requiring both “push” and “pull” communications
  • Avoids http polling for more efficiency and low latency


  • Each user is assigned a unique Jabber ID. 
  • XMPP server manages the messages published to a certain node (topic) and delivers the messages to all subscribers for that node.
  • Messages may contain payload.
  • Messages may be persistent.

XMPP Libraries for Application Programming

  • Smack API – Java API for XMPP clients.
  • Can be used to:
    • Connect to the XMPP server with user’s JID
    • Get the user’s roster from XMPP server
    • Sending and receiving different type of Stanzas (IQ, Message and Presence).
    • Publish messages to nodes 
    • Subscribe to nodes of interest.
    • File transfer/Group chat support also available.

Network Management over XMPP
  • Arista’s CloudVision framework Multi-Switch CLI extension uses XMPP to provide a shared message bus for managing and configuring switches. This is based on the idea from Internet of Things extension for XMPP ( 
  • Arista Switches run an XMPP client and respond to CLI commands. 
  • User can use any XMPP client (like iChat) on phone or PC to execute CLI on switches.
  • A single login to XMPP server gives secure access to all switches.
  • Switches can participate in group chats – meaning CLI can be executed on all participating switches in batch.
  • A Switch can be in more than one chat room at the same time. Command executed in a given chat room, is executed on all participating switches in that chat room.
  • Arista uses ejabberd XMPP server (included with fedora distro).
  • Arista uses SleekXMPP client.
  • If 2 switches are connected via XMPP, you can run CLI commands on switch A directly from switch B using xmpp send CLI command.
XMPP with Primefaces

  • Primefaces uses Atmosphere framework for implementing server push (PrimePush) -
  • Atmosphere comes with a plug-in for BOSH/XMPP (

  • Fun with XMPP and Google Talk -
  • Smack API -
  • XMPP Technology overview -
  • Arista’s Network Management over XMPP -

No comments:

15 sorting algorithms visualized in 5 minutes, with awesome arcade sounds

15 sorting algorithms visualized in 5 minutes, with awesome arcade sounds from r/programming