I’m using PubSub extension 0.6 for Smack against the Openfire server. I create a Node using PubSubManager but for some reason I kept getting a 404 error if I call getNode afterwards. I checked Openfire database and the node record was indeed inserted. Below is the code:
public class Test {
private static XMPPConnection conn;
public static void create(String id) throws Exception {
PubSubManager psm = new PubSubManager(conn);
LeafNode node = (LeafNode) psm.create(id);
}
public static void get(String id) throws Exception {
PubSubManager psm = new PubSubManager(conn);
Node node = psm.getNode(id);
}
public static void main(String[] args) throws Exception {
conn = new XMPPConnection(“localhost”);
conn.connect();
conn.login(“joe”, “joe”);
// create no problem
create(“org”);
// get call always fail with 404 error code
get(“org”);
}
}
Don’t use that old jar. Use a nightly build instead that has all that code already rolled in to Smack as well as some bug fixes.
http://www.igniterealtime.org/downloads/nightly_smack.jsp
To fix your problem, call **new PubSubManager(conn, “pubsub”);
**
I really need to update the example in the documentation.
Yes. That was indeed the problem. What I intended to do is to create a node under the pubsub service of the XMPP server. Calling new PubSubManager(conn) creates the node under my login user entry instead. So I couple of more questions:
- Is it legitimate to create a node under a user entity (In my case it’s joe@mydomain.com)? If it is not allowed then maybe PubSubManager.createNode(id) should throw some sort of exception instead?
2 Why a IQ info for the node always return 404 error even the node was created under a user entity?
Frankly, I don’t know why the create node is working, I would have to look at the processing on the server as to why it does not respond to the pubsub specific request with an error. As for createNode throwing an exception, it simply sends requests to the server. It is the servers job to succeed or fail, not the clients.
I think I may remvoe the single parameter consctructor, since I am not sure that it is valid in any case.