0
votes

I'm attempting to store persistent public data on an xmpp server using. Ideally, a user would be able to store a node on the server, and then retrieve that specific node later. This is all implemented on an openfire server, using strophe for the front end.

When I create the node, I use something like this:

$iq({
 type: 'set',
 to: 'pubsub.ubuntu',
 id: 'pubsubecreatenode1'
}).c('pubsub', {xmlns: Strophe.NS.PUBSUB})
.c('create', {
 node: "princely_musings"; 
});

which returns a result stanza with a create node, unless I've already created the node, in which case it returns:

<iq id="pubsubecreatenode1" xmlns="jabber:client" type="error" 
    from="pubsub.ubuntu" 
    to="admin@ubuntu">
 <pubsub xmlns="http://jabber.org/protocol/pubsub">
  <create node="princely_musings"></create>
 </pubsub>
 <error code="409" type="cancel">
  <conflict xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"></conflict>
 </error>
</iq>

I also publish to it using this:

$iq({
 type: "set",
 to: 'pubsub.ubuntu',
 id: 'pub1'
}).c("pubsub", {
 xmlns: Strophe.NS.PUBSUB
}).c("publish", {
 node: "princely_musings"
}).c("item")
.c("object", {xmlns: "http://www.w3.org/2005/Atom"})
.h("somedata");

Which also returns a successful IQ result stanza.

However, when I go to discover the nodes, I get an item-not-found error when requesting a specific node (princely_musings), or an empty list when not specifying a node.

$iq({
    type: "get",
    to: 'pubsub.ubuntu',
    id: "disco1"
}).c("query", {
    xmlns: Strophe.NS.DISCO_ITEMS
}); 

and alternatively for a specific node:

.c("query", {
  xmlns: Strophe.NS.DISCO_ITEMS,
  node: "princely_musings"
});

These return:

<iq id="disco1" xmlns="jabber:client" type="result" 
    from="pubsub.ubuntu" 
    to="admin@ubuntu">
 <query xmlns="http://jabber.org/protocol/disco#items"></query>
</iq>

and

<iq id="disco1" xmlns="jabber:client" type="error" 
    from="pubsub.ubuntu" 
    to="admin@ubuntu">
 <query xmlns="http://jabber.org/protocol/disco#items" 
        node="princely_musings">
 </query>
 <error code="404" type="cancel">
  <item-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"></item-not-found>
 </error>
</iq>

The conflict errors that I arise when I try to create an existing node lead me to believe that I am appropriately storing the nodes on the server, however I can't determine why my discovery iq stanzas are failing to find anything. Is there something I'm missing or have misconfigured in these calls, or is there another protocol I should be using for this operation?

2

2 Answers

0
votes

So I've figured this out. I should have been looking at the openfire database in ofPubsubItem to determine whether I had actually been creating items (I wasn't). This was directly because the default node configuration. The create IQ should've looked more like this:

$iq({
        type: 'set',
        to: 'pubsub.ubuntu',
        from: 'create1'
    }).c('pubsub', {xmlns: Strophe.NS.PUBSUB})
.c('create', { node: 'princely_musings' }).up()
.c('configure')
.c('x', {xmlns: 'jabber:x:data', type: 'submit'})
.c('field', {'var': 'pubsub#persist_items'}).c('value').t('1').up().up()
.c('field', {'var': 'pubsub#access_model'}).c('value').t('open').up().up()
.c('field', {'var': 'pubsub#publish_model'}).c('value').t('open')
0
votes

i've solved this question,the problem is not whether there are items in table 'ofPubsubItem'

i send 'iq' to server 'pubsub.myserver' instead of 'myserver',thats the keypoint for openfire pubsub

<iq to='pubsub.myserver'
type='set'
id='create'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<create/>
</pubsub>
</iq>

thx anyway