powered by Jive Software

XEP-0060: PubSub subscription problems with bare jid

Hello,

I have a number of connections for the same user (same bare jid,automatically created resource identifier). Lets say:

lezebre@example.com/aaaaaa

lezebre@example.com/bbbbbb

All users subscribe to the same pubsub node (node.lezebre) and each user should get an notification event if an item is published or retracted. The best way to do this would be to create a temporary subscription (XEP-0060 12.4) using the full jid, but unfortunately openfire 3.8.2 does not support this feature, right?

So my idea was to create a subscription with a bare jid to that node having the assumption publishing to the bare jid would cause openfire to send notifications to all instances of this user.

Subscribing works:

<subscribe node='node.lezebre' jid='lezebre@example.com'/>

<options>

  <x xmlns='jabber:x:data' type='submit'>

    <field var='FORM_TYPE' type='hidden'>

      <value>[http://jabber.org/protocol/pubsub#subscribe_options](http://jabber.org/protocol/pubsub#subscribe_options)</value>

    </field>

    <field var='pubsub#include_body'>

      <value>1</value>

    </field>

    <field var='pubsub#subscription_type'>

      <value>items</value>

    </field>

  </x>

</options>
<subscription node="node.lezebre" jid="lezebre@example.com" subid="Tg8Urhi3W04yknlyxNoxU8O0iEDVuFW830BuHwg3" subscription="subscribed">

  <subscribe-options/>

</subscription>

So both users are connected now and lezebre@example.com/aaaaaa publishes an item to node:

<publish node='node.lezebre'>

  <item id='32c1f0461a7ac9164a838b53fdc42014'>

    <payload xmlns='...'>payload</payload>

  </item>

</publish>
<items node="node.lezebre">

  <item id="32c1f0461a7ac9164a838b53fdc42014">

  </item>

</items>
<header name="pubsub#subid">Tg8Urhi3W04yknlyxNoxU8O0iEDVuFW830BuHwg3</header>

User lezebre@example.com/aaaaaa gets this notification, but lezebre@example.com/bbbbbb does not. Same is if lezebre@example.com/bbbbbb publishes an item he gets this event, but lezebre@example.com/aaaaaa does not. Am i doing something wrong or is this a bug?

If i subscribe both users to the node using the full jid it works perfectly, but as the resource identifier is completely random it creates more and more subscriptions in the database that never will be deleted again. So that’s not a good idea.

Can anybody please help me on this?

Thanks alot.

  1. It seems that openfire treats subscriptions and jids as 1:1 and not 1:n, so when sending something to a bare jid it only sends it to the current connection, right? And not to all connections that have the same bare jid. Is that wanted?

  2. When is openfire going to support temporary subscriptions XEP-0060 12.4?

You should get the subscription sent to multiple users with the same highest priority if you set the route.all-resources property to true. This has nothing to do with pubsub specifically, but is a feature of how messages can be routed by the server.

I have done what you are trying to do (temporary subscriptions) by adding a plugin to the server which will delete subscriptions when the session closes (via a session listener). This has the same effect as the option in the newer version of the spec.

I have no idea when someone will be updating Openfires implementation to a newer version of the spec.

Thanks alot! That was a good hint.

What plugin do you use for that? It would be quite helpful.

Unfortunately, I don’t have the source code available, but I wrote a simple one that is a PresenceListener and registers itself for presence info on initialization. Then on handleUnavailableSession() simply looked up the subscriptions on the node in question for the JID in question and called node.cancelSubscription()