I’ve been having lots of trouble getting PubSub working on openfire.
From the documentation here (http://www.xmpp.org/extensions/xep-0060.html) I expect openfire to return certain responses when things happen, but I am finding that I can’t get openfire to tell me anything about the PubSub entities I’ve created. The only way I know they exist is by going to the database, but even when using the information I’m looking up in the DB I still can’t get a client to receive notifications on a node they subscribe to.
So, without further ado, here’s what I’m sending and receiving for each step.
1) Create a node
What I send:
What I get back:
Shouldn’t I get back a pubsub tag back with an ID for the node?
2) Subscribe to the node created in step 1
What I send:
What I get back:
Shouldn’t I get back a pubsub tag with an ID for the subscription?
3) Check the subscription for test user created in step 2
What I send:
What I get back:
Shouldn’t I get back an element describing the subscription I just created in step 2? (The record is created in the database)
Is there some sort of configuration I’m missing for openfire? So far I’ve found a real lack of documentation for pubsub support on openfire so I don’t know what I am doing incorrectly. I have spent a day working on this and have gotten exactly nowhere, so please shed some light on what I am missing.
Thanks in advance.
I believe that you should only get back a response with a NodeID if you create an “instant node”. See http://www.xmpp.org/extensions/xep-0060.html#owner-create, Example 117 and 118 vs. http://www.xmpp.org/extensions/xep-0060.html#owner-create-default, Example 119 and 121.
As for as subscribing to a node and getting the subscription information – how are you viewing the raw XML? Are you using the Smack debugger/enhanced debugger? I have found then when using the built in enhanced debugger (for PubSub events specifically) many times there is more information displayed in the “Raw Sent/Recieved Packets” tabs than what is displayed in the “All Packets” tab.
What I find more intriguing is that you were able to create a node and subscribe to it using two different user ID’s. I am having trouble subscribing to a node I created unless the subscription request is sent to the owner of the node which created it. E.g. I can send a node create request addressed to “my.xmpp.server”, however when trying to subscribe to that node as another user – the only way I can subscribe to it is if I address it to “firstname.lastname@example.org”. If I send the subscribe request to “my.xmpp.server” I get a 404 item-not-found error.
I was wondering if you can share the code you use to create/subscribe to nodes. Which API are you using for PubSub?
To view the rawXML I am just printing trace from a few test case java classes.
I am not familiar with the debugger you mentioned, can you point me to more info about it?
Creating a node with one test account and subscribing to it with another account is the only way that I could get things to “work” (not get ‘item-not-found’ response). Perhaps there is something I can learn by looking at a more detailed log of the traffic with the debugger you mentioned.
As far as the API I am using, I have tried su-smack with similar results so I started writing my own helper classes extending the smack API.
The helper classes just aid in generating the PubSub stanzas to send to the server (the XML in the first post of this thread).
I am running into another interesting behavior. When I include the su-smack.jar to my build path and try to run my helper classes I occasionally get this error: java.lang.ClassNotFoundException: se.su.it.smack.pubsub.elements.SubscriptionElement
I am not explicitly referencing su-smack anywhere in this code.
If I remove the su-smack.jar file from the build path then it works as I’ve described, so I am suspicious that maybe there is some parsing error of the pubsub responses that is getting swallowed.
To enable the debugger, just set XMPPConnection.DEBUG_ENABLED = true (referenced in a static way). If you add the smackx-debug.jar you get the “enhanced” debugger, without this JAR file you get the standard debugger. This assumed of course that you are using the Smack API.
As for the ClassNotFoundException – although you do not reference it directly in your code anywhere, when you drop the su-smack.jar file into your build path it automagically registers with the Smack API (via the smack.providers file in the META-INF file in the JAR file). Don’t know the inner workings here, however it could be that when the JAR is registered and data arrives it tries to do some parsing (re: subscriptions) and throws the error while trying to do so.
I’m still preplexed why the simple create/subscribe model you describe works for you but does not work for me. What version of OpenFire are you using?
The version of OpenFire that I’m using is Openfire 3.5.2
The version of Smack that I’m using is 3.0.4
As far as this ‘working’ for me I’d have to disagree
I am going to get this debugger up and running and see what there is to see. I’ll post an update when I have more info.
OK… I worked out my problems.
I was addressing all my create/subscribe requests to “my.xmpp.server” (obviously closed environment – DNS managed by /etc/hosts ). What I needed to do was address my requests to “pubsub.my.xmpp.server”. Now I do not know why this is, but when I address create/subscribe requests to “pubsub.my.xmpp.server” – I can create and subscribe and all works well. I’m gonna have a look at the server source code to see why this may be.
Again, I’d strongly recommend enabling the enhanced debugger with Smack and have a look at the Raw packets… I’ve seen data just get lost somewhere in translation while bubbling up through the Smack API.
I’m trying to figure out how to invoke the debugger console. From the documentation here (http://www.igniterealtime.org/builds/smack/docs/latest/documentation/debugging.h tml) it “looks” like this console should pop up when you start your application via the command line provided that you’ve enabled debugging. But that’s not happening for me. What am I missing?
EDIT: I got it to work after I set the -Dsmack.debugEnable=true property for the java VM. It didnt pick up the XMPPConnection.DEBUG_ENABLED=true.
Okay! So I’ve made some progress!
It turns out that this code:
XMPPConnection con = new XMPPConnection(config);
catch (XMPPException e)
public void processPacket(Packet pack)
System.out.println("Recv : " + pack.toXML());
for some reason “loses” large portions of the response from the server.
For example when I do a subscribe operation the System.out.println writes the response as:
But in the debugging console’s Raw Received Packets tab I see:
Maybe some field or data related to the response that is being hidden by the Packet.toXML() method?
This is the exact activity I have been seeing. Not sure why this is – but for the most part I always refer back to the debugger / Raw Packets to make sure I didn’t miss anything.