AnsweredAssumed Answered

Problem with PubSub nodes (Smack 4.2.1)

Question asked by I Iachimoe on Aug 18, 2017
Latest reply on Aug 25, 2017 by I Iachimoe

I am having some trouble with pubsub working against both openfire and ejabberd. Below is an example for openfire (code is in scala):

 

val manager = PubSubManager.getInstance(connection, connection.getUser.asBareJid())

val config = new ConfigureForm(DataForm.Type.submit)

config.setPersistentItems(true)

config.setDeliverPayloads(true)

config.setAccessModel(AccessModel.presence)

config.setPublishModel(PublishModel.publishers)

config.setMaxItems(1)

config.setSubscribe(true)

val node = manager.createNode("myTestNode", config).asInstanceOf[LeafNode]

 

This produces the following request/response:

<iq to='user@example.com' id='ufY3l-26' type='set'><pubsub xmlns='http://jabber.org/protocol/pubsub'><create node='myTestNode'/><configure><x xmlns='jabber:x:data' type='submit'><field var='pubsub#persist_items' type='boolean'><value>1</value></field><field var='pubsub#deliver_payloads' type='boolean'><value>1</value></field><field var='pubsub#access_model' type='list-single'><value>presence</value></field><field var='pubsub#publish_model' type='list-single'><value>publishers</value></field><field var='pubsub#max_items' type='text-single'><value>1</value></field><field var='pubsub#subscribe' type='boolean'><value>1</value></field></x></configure></pubsub></iq>

 

<iq type="result" id="ufY3l-26" from="user@example.com" to="user@example.com/Work"/>

 

 

Then we publish to the node:

val payload = new SimplePayload(null, null, content)

val payloadItem = new PayloadItem(null, payload)

node.publish(payloadItem)

 

which produces the following request/response:

<iq to='user@example.com' id='ufY3l-28' type='set'><pubsub xmlns='http://jabber.org/protocol/pubsub'><publish node='myTestNode'><item><myXmlPayload /></item></publish></pubsub></iq>

 

<iq type="result" id="ufY3l-28" from="user@example.com" to="user@example.com/Work"/>

 

 

However, when trying to retrieve the node info in a later session like this:

val manager = PubSubManager.getInstance(connection, connection.getUser.asBareJid())

manager.getNode[LeafNode]("myTestNode")

 

We get the following request/response:

<iq to='user@example.com' id='ufY3l-76' type='get'><query xmlns='http://jabber.org/protocol/disco#info' node='myTestNode'></query></iq>

 

<iq type="error" id="ufY3l-76" from="user@example.com" to="user@example.com/Work"><query xmlns="http://jabber.org/protocol/disco#info" node="myTestNode"/><error code="404" type="cancel"><item-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>

 

However, the node still clearly exists, because if we try to recreate it, we get an error:

<error code="409" type="cancel"><conflict xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error>

 

Any suggestions as to where I’m going wrong would be great!

 

Best,

Iachimoe

Outcomes