我試圖在xmpp服務器上使用存儲持久公共數據。理想情況下,用戶可以在服務器上存儲節點,然後稍後檢索該特定節點。這全部在openfire服務器上實現,使用strophe作爲前端。XMPP Pubsub節點發現,找不到項目
當我創建的節點,我用的是這樣的:
$iq({
type: 'set',
to: 'pubsub.ubuntu',
id: 'pubsubecreatenode1'
}).c('pubsub', {xmlns: Strophe.NS.PUBSUB})
.c('create', {
node: "princely_musings";
});
它返回一個結果節以創建節點,除非我已經創建的節點,在這種情況下,它返回:
<iq id="pubsubecreatenode1" xmlns="jabber:client" type="error"
from="pubsub.ubuntu"
to="[email protected]">
<pubsub xmlns="http://jabber.org/protocol/pubsub">
<create node="princely_musings"></create>
</pubsub>
<error code="409" type="cancel">
<conflict xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"></conflict>
</error>
</iq>
我也是用這個發佈到它:
$iq({
type: "set",
to: 'pubsub.ubuntu',
id: 'pub1'
}).c("pubsub", {
xmlns: Strophe.NS.PUBSUB
}).c("publish", {
node: "princely_musings"
}).c("item")
.c("object", {xmlns: "http://www.w3.org/2005/Atom"})
.h("somedata");
其中也返回一個成功的IQ結果節。
但是,當我去發現節點時,當請求特定節點(princely_musings
)時,出現項未找到錯誤,或未指定節點時出現空列表。
$iq({
type: "get",
to: 'pubsub.ubuntu',
id: "disco1"
}).c("query", {
xmlns: Strophe.NS.DISCO_ITEMS
});
還或者特定節點:
.c("query", {
xmlns: Strophe.NS.DISCO_ITEMS,
node: "princely_musings"
});
這些返回:
<iq id="disco1" xmlns="jabber:client" type="result"
from="pubsub.ubuntu"
to="[email protected]">
<query xmlns="http://jabber.org/protocol/disco#items"></query>
</iq>
和
<iq id="disco1" xmlns="jabber:client" type="error"
from="pubsub.ubuntu"
to="[email protected]">
<query xmlns="http://jabber.org/protocol/disco#items"
node="princely_musings">
</query>
<error code="404" type="cancel">
<item-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"></item-not-found>
</error>
</iq>
衝突的錯誤,我出現時,我嘗試創建一個現有的節點引導我相信我am正確地存儲服務器上的節點,但我無法確定爲什麼我的發現iq節未能找到任何東西。在這些調用中是否存在某些我錯過或錯誤配置的內容,或者是否存在另一個應該用於此操作的協議?
我覺得你的問題可能已經從我原來的問題略有不同,雖然看着文我的問題我也看到,我一直在使用格式不正確的服務器地址。我編輯了問題以使用正確格式的pubsub。 但是,仍然很重要的一點是,persist_items應該在節點配置中正確設置,否則會在會話之間丟失數據。 –
nmarsh
2015-04-30 14:17:07