powered by Jive Software

Smack pubsub getItem from leafnode error

Hi all,

I am new to smack pubsub.

I am using smackx to work with pubsub openfire.

Right now, there is serious issue in my code, I can’t get item back from node.

if i use

// retrieve nodes
          private void retrieveNodes(Connection conn) {
                    // Create a pubsub manager using an existing Connection
                    PubSubManager mgr = new PubSubManager(conn);                     // Get the node
                    LeafNode node = null;
                    try {
                              node = (LeafNode) mgr.getNode("testNode");
                    } catch (XMPPException e1) {
                              // TODO Auto-generated catch block
                    node.addItemEventListener(new ItemEventCoordinator());                    
          }           class ItemEventCoordinator implements ItemEventListener {
                    public void handlePublishedItems(ItemPublishEvent items) {
                              System.out.println("Item count: " + items.getItems().size());
                              Collection<? extends Item> itemss = items.getItems();
                              for (Item item : itemss) {
                                        PayloadItem pi = (PayloadItem) item;                                         System.out.println("item: " + pi.toXML());

it only return the last one item with full payload.

if i use any methods like:

DiscoverItems nodeItems = node.discoverItems();
Iterator<org.jivesoftware.smackx.packet.DiscoverItems.Item> i =

then, only return items without payload.

I try to use:

LeafNode node = (LeafNode) mgr.getNode("testNode");
List<? extends PayloadItem> items = node.getItems();

everytime, it returns

<iq type="error" id="Mj6e4-5" from="pubsub.stan-desktop" to="user1@stan-desktop/Smack"><pubsub xmlns="http://jabber.org/protocol/pubsub"><items node="testNode" max_items="100"/></pubsub><error code="400" type="modify"><bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/><subid-required xmlns="http://jabber.org/protocol/pubsub#errors"/></error></iq>

I searched the all fourm and internet wherever I can, but no answers works for me.

If anyone has some idea about how to retrieve all items with payload in the nodes, please help.



Try using other methods like

                                    List<Item> items = node.getItems(subscriptionId);

and to get more details of more then one subscribers use


because node.getItems() ( with no argument ) function is sending wrong stanza to server

Actually, that is caused by the fact that the Openfire implementation follows an older version of the spec in which the subscription ID was always required, even if there is only one subscription.

The wrong stanza isn’t being sent, there is just a small version mismatch in which Openfire doesn’t support getItems() which is only valid if there is one subscription.