問題描述
我正在嘗試使用最新的 Smackx 中繼來獲取并訂閱一個 pubsub 節點.但是,openfire 只是向我發送了一個錯誤:找不到項目 (404).
I'm trying to use the latest Smackx trunk to get and then subscribe to a pubsub node. However, openfire just sends me a back an error: item not found (404).
我正在從 ColdFusion 實例化 java 對象,所以我的代碼片段可能看起來很有趣,但也許有人能告訴我我忘記了什么.
I am instantiating the java objects from ColdFusion, so my code snippets might look funny but maybe someone will be able to tell me what I've forgotten.
這是我創建節點的方式:
Here's how I create the node:
ftype = createObject("java", "org.jivesoftware.smackx.pubsub.FormType");
cform = createObject("java", "org.jivesoftware.smackx.pubsub.ConfigureForm").init(ftype.submit);
cform.setPersistentItems(true);
cform.setDeliverPayloads(true);
caccess = createObject("java", "org.jivesoftware.smackx.pubsub.AccessModel");
cform.setAccessModel(caccess.open);
cpublish = createObject("java", "org.jivesoftware.smackx.pubsub.PublishModel");
cform.setPublishModel(cpublish.open);
cform.setMaxItems(99);
manager = createObject("java", "org.jivesoftware.smackx.pubsub.PubSubManager").init(XMPPConnection);
myNode = manager.createNode("subber", cform);
這就是我試圖達到它的方式(在不同的代碼部分中):
And here's how I am trying to get to it (in a different section of code):
manager = createObject("java", "org.jivesoftware.smackx.pubsub.PubSubManager").init(XMPPConnection);
myNode = manager.getNode("subber");
在創建節點后,我似乎可以像這樣發布到它:
Immediately upon creating the node I seem to be able to publish to it like so:
payload = createObject("java", "org.jivesoftware.smackx.pubsub.SimplePayload").init("book","pubsub:test:book","<book xmlns='pubsub:test:book'><title>Lord of the Rings</title></book>");
item = createObject("java", "org.jivesoftware.smackx.pubsub.Item").init(payload);
myNode.publish(item);
但是,導致我的代碼出錯的是 getNode() 調用.
However, it is the getNode() call that is causing my code to error.
我已經通過檢查我的 openfire 服務器使用的數據庫來驗證正在創建節點.我可以在那里看到它們,正確地歸因于葉節點等.
I have verified that the nodes are being created by checking the DB used by my openfire server. I can see them in there, properly attributed as leaf nodes, etc.
有什么建議嗎?還有其他人在用 XMPP 和 ColdFusion 做任何事情嗎?我在使用 CF 發送和接收消息方面取得了巨大成功,而 Smack 還沒有讓 pubsub 工作:)
Any advice? Anyone else out there doing anything with XMPP and ColdFusion? I have had great success sending and receiving messages with CF and Smack just haven't had the pubsub working yet :)
謝謝!
推薦答案
已回答:
PubSubManager 類還有第二個方法,它接受兩個參數,一個連接和一個 to 參數.顯然 Openfire 需要這個 to 參數,經過一些實驗,我發現它可以使用 pubsub.your.xmpp.address
There is a second method on the PubSubManager class that accepts two arguments, a connection and a to parameter. Apparently Openfire requires this to parameter and after some experimenting i discovered that it works using pubsub.your.xmpp.address
manager = createObject("java", "org.jivesoftware.smackx.pubsub.PubSubManager").init(XMPPConnection,"pubsub.127.0.0.1");
這篇關于嘗試使用 Smackx pubsub 獲取節點時未找到項目(404)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!