The pontarius-xmpp package

[ Tags: benchmark, bsd3, library, network ] [ Propose Tags ]

Pontarius XMPP is a work in progress implementation of RFC 6120 ("XMPP CORE"), RFC 6121 ("XMPP IM"), and RFC 6122 ("XMPP ADDR"). While in alpha, Pontarius XMPP works quite well and fulfills most requirements of the RFCs.

[Skip to Readme]


Versions,,,,,,,,,,,,,,,,,,,,,, 0.4.3, 0.4.4, 0.4.5, 0.5.0, 0.5.1, 0.5.2, 0.5.3, 0.5.4
Change log
Dependencies attoparsec (>=, base (>4 && <5), base64-bytestring (>=, binary (>=0.4.1), bytestring (>=, conduit (>=1.0.1), containers (>=, crypto-api (>=0.9), crypto-random (>=0.0.5), cryptohash (>=0.6.1), cryptohash-cryptoapi (>=0.1), data-default (>=0.2), dns (>=0.3.0), hslogger (>=1.1.0), iproute (>=1.2.4), lifted-base (>=, mtl (>=, network (>=, pureMD5 (>=, random (>=, resourcet (>=0.3.0), split (>=, stm (>=, stringprep (>=1.0.0), template-haskell (>=2.5), text (>=, tls (>=1.1.3), tls-extra (>=0.6.0), transformers (>=, unbounded-delays (>=0.1), void (>=0.5.5), xml-conduit (>=, xml-picklers (>=0.3.3), xml-types (>=0.3.1) [details]
License BSD3
Copyright Dmitry Astapov, Pierre Kovalev, Mahdi Abdinejadi, Jon Kristensen, IETF Trust, Philipp Balzarek
Author Jon Kristensen, Philipp Balzarek
Category Network
Home page
Bug tracker
Source repository head: git clone git://
this: git clone git://
Uploaded Tue Feb 25 20:20:48 UTC 2014 by JonKristensen
Distributions NixOS:0.5.4
Downloads 5069 total (46 in the last 30 days)
Rating 2.0 (1 ratings) [clear rating]
  • λ
  • λ
  • λ
Status Docs available [build log]
Successful builds reported [all 1 reports]
Hackage Matrix CI





Enable Template Haskell support


Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info


Maintainer's Corner

For package maintainers and hackage trustees

Readme for pontarius-xmpp-

[back to package description]

Welcome to Pontarius XMPP!

Pontarius XMPP is an active work in progress to build a Haskell XMPP client library that implements the capabilities of RFC 6120 ("XMPP CORE"), RFC 6121 ("XMPP IM"), and RFC 6122 ("XMPP ADDR"). Pontarius XMPP is part of the Pontarius project, an effort to produce free and open source, uncentralized, and privacy-aware software solutions.

While in alpha, Pontarius XMPP works quite well and fulfills most requirements of the RFCs.


Pontarius XMPP requires GHC 7.0, or later.

You will need the ICU Unicode library and it's header files in order to be able to build Pontarius XMPP. On Debian, you will need to install the libicu-dev package. In Fedora, the package is called libicu-devel.

Note to users of GHC 7.0 and GHC 7.2: You will need cabal-install, version 0.14.0 or higher, or the build will fail with an "unrecognized option: --disable-benchmarks" error. The versions 1.16.0 and higher might not build on your system; if so, install 0.14.0 with "cabal install cabal-install-0.14.0".

Note to users of GHC 7.2.1: Due to a bug, recent versions of the binary package wont build without running "ghc-pkg trust base".

Note to users of GHC 7.0.1: You will want to configure your Cabal environment (including cabal-install) for version of bytestring.

Getting started

The latest release of Pontarius XMPP, as well as its module API pages, can always be found at the Pontarius XMPP Hackage page.

Note: Pontarius XMPP is still in its Alpha phase. Pontarius XMPP is not yet feature-complete, it may contain bugs, and its API may change between versions.

The first thing to do is to import the modules that we are going to use. We are also using the OverloadedStrings LANGUAGE pragma in order to be able to type <code>Text</code> values like strings.

{-# LANGUAGE OverloadedStrings #-}

import Network.Xmpp

import Control.Monad
import Data.Default
import System.Log.Logger

Pontarius XMPP supports hslogger logging. Start by enabling console logging.

updateGlobalLogger "Pontarius.Xmpp" $ setLevel DEBUG

When this is done, a <code>Session</code> object can be acquired by calling <code>session</code>. This object will be used for interacting with the library.

result <- session
              (Just (\_ -> ( [scramSha1 "username" Nothing "password"])
                           , Nothing))

The three parameters above are the XMPP server realm, a SASL handler (for authentication), and the session configuration settings (set to the default settings). <code>session</code> will perform the necessary DNS queries to find the address of the realm, connect, establish the XMPP stream, attempt to secure the stream with TLS, authenticate, establish a concurrent interface for interacting with the stream, and return the <code>Session</code> object.

The return type of <code>session</code> is <code>IO (Either XmppFailure Session)</code>. As <code>XmppFailure</code> is an <code>Control.Monad.Error</code> instance, you can utilize the <code>ErrorT</code> monad transformer for error handling. A more simple way of doing it could be doing something like this:

sess <- case result of
            Right s -> return s
            Left e -> error $ "XmppFailure: " ++ (show e)

Next, let us set our status to Online.

sendPresence def sess

Here, <code>def</code> refers to the default <code>Presence</code> value, which is the same as <code>Presence Nothing Nothing Nothing Nothing Available []</code>.

Now, let's say that we want to receive all message stanzas, and echo the stanzas back to the sender. This can be done like so:

forever $ do
    msg <- getMessage sess
    case answerMessage msg (messagePayload msg) of
        Just answer -> sendMessage answer sess
        Nothing -> putStrLn "Received message with no sender."

You don't need to worry about escaping your <code>Text</code> values - Pontarius XMPP (or rather, xml-picklers) will take care of that for you.

Additional XMPP threads can be created using <code>dupSession</code> and <code>forkIO</code>.

For a public domain example of a simple Pontarius XMPP (Cabal) project, refer to the examples/echoclient directory.

More information

Feel free to contact Jon Kristensen if you have any questions or comments.

You are also welcome to join the #pontarius IRC channel at Freenode.