Using sat-pubsub, a great pubsub component

In the continuity with the previous post about jp, the following article present sat_pubsub, a XMPP Publish-Subscribe (Pubsub) Service Component, build for the need of the « Salut à Toi » project.

Salut à toi (SàT) is a unique XMPP client. As its official description says, it's a "multipurpose, multi front-end, free (libre) and decentralized communication tool". It has been actively developed by Jérôme Poisson (Goffi) and Adrien Cossa (Souliane) since 2008.

sat_pubsub allows us to use our own up-to-date persistent pubsub service.

This article is composed of several sections

Why sat_pubsub ?

There are three main reasons to use sat_pubsub.

First, the XMPP servers come with variable pubsub support. Using an external component allows users to benefits constant features independent of the XMPP server or provider.

Secondly, sat_pubub is the only free (libre) implementation that support Pubsub MAM (Message Archive Management). It allows one to research a pubsub node. This feature is used to research blog post in the database.

Thirdly, sat_pubsub is used to test new functionalities like the ability to restrict blog post to specific group of contacts (think about circles on Google+). [ref]See the following blog post for more information.[/ref].

Let's install it !

This section describes the installation process of sat_pubsub in a python virtualenv. Unfortunately, I have encountered difficulties to install twisted, a dependency of SàT, in a virtualenv with pip because my production machine has no compiler. I managed to avoid the problem by installing python2-twisted (the distribution package) then the virtualenv was created with the option --system-site-packages to give it access to the system packages. Thereafter, it is possible to install sat_tmp, a small python module that monkey patch wokkel, a dependency of sat_pubsub.

$ sudo apt-get install python2-twisted
[...]
$ hg clone http://repos.goffi.org/sat_tmp
$ cd sat_tmp/
$ virtualenv env -ppython2.7 --system-site-packages
$ source env/bin/activate
(env)$  python2 setup.py install
(env)$ cd ../
(env)$ hg clone https://repos.goffi.org/sat_pubsub
(env)$ cd sat_pubsub
(env)$ python2 setup.py install

Setup the database

According to the official documentation, we need to create the database and install the SQL schema.

$ sudo -u postgres createuser -d -P `whoami`
$ createdb pubsub
$ psql pubsub < sat_pubsub/db/pubsub.sql

Configure Prosody

In order to use sat_pubsub, we need to declare it in our prosody config file. Once again, the information is available in the documentation. Two files need to be modified:

  • /etc/prosody/prosody.cfg.lua
[...]
modules_enabled = {
    [...]
    "delegation";
    "privilege";
}
[...]
  • /etc/prosody/conf.avail/your_domain.cfg.lua

This file defines the domain configuration of your XMPP server.

This is a copy of the configuration for the agayon server. The pubsub component is available at the address pubsub.agayon.be. The following configuration:

  • enables pubsub MAM,
  • uses the component for microblogging activity,
  • announces the pubsub nodes and items in disco requests,
  • lets the component access the roster and presence informations (used for PEP).
VirtualHost "agayon.be"
    enabled = true
    [...]
    privileged_entities = {

            ["pubsub.agayon.be"] = {
            roster = "get";
            message = "outgoing";
            presence = "roster";
            },
       }
    delegations = {
                ["urn:xmpp:mam:1"] = {
                        filtering = {"node"};
                        jid = "pubsub.agayon.be";
                },
                 ["http://jabber.org/protocol/pubsub"] = {
                        jid = "pubsub.agayon.be";
                 },
                 ["http://jabber.org/protocol/pubsub#owner"] = {
                        jid = "pubsub.agayon.be";
                 },
                 ["https://salut-a-toi/protocol/schema:0"] = {
                        jid = "pubsub.agayon.be";
                 },
                 ["http://jabber.org/protocol/disco#items:*"] = {
                        jid = "pubsub.agayon.be";
                 },
            }


Component "pubsub.agayon.be"
        component_secret = "shared_secret"
        modules_enabled = {"delegation", "privilege"}

Launch

(env)$ twistd  sat_pubsub  --jid=pubsub.agayon.be --secret=shared_secret --rhost=127.0.0.1 \
--rport=5347 --backend=pgsql --dbuser=user --dbpass=pass_psql --dbname=pubsub --dbhost=localhost --dbport=5432

Let's use it !

Once prosody is restarted, the component is accessible through any XMPP client. See the following example with jp.

$ jp info disco pubsub.agayon.be -c
Features

http://jabber.org/protocol/disco#items
http://jabber.org/protocol/pubsub#auto-create
http://jabber.org/protocol/pubsub#config-node
http://jabber.org/protocol/pubsub#create-nodes
http://jabber.org/protocol/pubsub#delete-any
http://jabber.org/protocol/pubsub#delete-nodes
http://jabber.org/protocol/pubsub#groupblog
http://jabber.org/protocol/pubsub#instant-nodes
http://jabber.org/protocol/pubsub#item-ids
http://jabber.org/protocol/pubsub#meta-data
http://jabber.org/protocol/pubsub#outcast-affiliation
http://jabber.org/protocol/pubsub#persistent-items
http://jabber.org/protocol/pubsub#publish
http://jabber.org/protocol/pubsub#publish-options
http://jabber.org/protocol/pubsub#publisher-affiliation
http://jabber.org/protocol/pubsub#purge-nodes
http://jabber.org/protocol/pubsub#retract-items
http://jabber.org/protocol/pubsub#retrieve-affiliations
http://jabber.org/protocol/pubsub#retrieve-default
http://jabber.org/protocol/pubsub#retrieve-items
http://jabber.org/protocol/pubsub#retrieve-subscriptions
http://jabber.org/protocol/pubsub#subscribe
https://salut-a-toi.org/spec/pubsub_admin:0
https://salut-a-toi/protocol/schema:0
jabber:iq:version
urn:xmpp:mam:2
urn:xmpp:order-by:0

Identities

┌───────┬─────────┬───────────────────────────┐
│catego  type     name                      │
├┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┤
│pubsub  service  Salut à Toi pubsub service│
└───────┴─────────┴───────────────────────────┘

Items

┌─────────────────┬───────────────────┬─┐
│entity            node               │
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┼┄┤
│pubsub.agayon.be  be.agayon.errol:0  │
│pubsub.agayon.be  tests              │
│pubsub.agayon.be  Agayon             │
└─────────────────┴───────────────────┴─┘

The following commands are used to create a node, subscribe to it and edit an item (see the previous article).

$ jp pubsub node create -s pubsub.agayon.be -n node_name
$ jp pubsub subscribe -s pubsub.agayon.be -n node_name
$ jp pubsub edit -s pubsub.agayon.be -n node_name

The default text editor is then opened. It is possible to directly edit a XML file. This command is useful for debugging purpose.

About Agayon XMPP service

All the tests described in this blog are realized on the Agayon.be XMPP service. It is not opened for registration but having this field of experimentation is great to learn, practice and question the potential uses of XMPP. I use it with several accounts, depending on my use:

Most moderns XEPs are enabled in order to provide an up-to-date experience: PEP, Carbon, Stream Management, persistent pubsub, MAM, SRV records over TLS (useful to pass blocking WiFi accesses), etc.

Future of SàT

In a near future, the SàT project will make great announcements about new uses of pubsub. I hope this article will make you want to install sat_pubsub and experiment with nodes, data and notifications.

Stay tuned !

Links

links

social