2014-11-08 28 views
0

我試圖在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節未能找到任何東西。在這些調用中是否存在某些我錯過或錯誤配置的內容,或者是否存在另一個應該用於此操作的協議?

回答

0

所以我想通了。我應該一直在查看ofPubsubItem中的openfire數據庫,以確定我是否真的創建了項目(我沒有)。這是因爲默認的節點配置。在創建IQ應該已經看到更多這樣的:

$iq({ 
     type: 'set', 
     to: 'pubsub.ubuntu', 
     from: 'create1' 
    }).c('pubsub', {xmlns: Strophe.NS.PUBSUB}) 
.c('create', { node: 'princely_musings' }).up() 
.c('configure') 
.c('x', {xmlns: 'jabber:x:data', type: 'submit'}) 
.c('field', {'var': 'pubsub#persist_items'}).c('value').t('1').up().up() 
.c('field', {'var': 'pubsub#access_model'}).c('value').t('open').up().up() 
.c('field', {'var': 'pubsub#publish_model'}).c('value').t('open') 
0

我已經解決了這個問題,這個問題不在於是否有表項的ofPubsubItem「

我送「智商」服務器' 「而不是‘MYSERVER’,pubsub.myserver多數民衆贊成Openfire的發佈 - 訂閱關鍵點

<iq to='pubsub.myserver' 
type='set' 
id='create'> 
<pubsub xmlns='http://jabber.org/protocol/pubsub'> 
<create/> 
</pubsub> 
</iq> 

THX反正

+0

我覺得你的問題可能已經從我原來的問題略有不同,雖然看着文我的問題我也看到,我一直在使用格式不正確的服務器地址。我編輯了問題以使用正確格式的pubsub。 但是,仍然很重要的一點是,persist_items應該在節點配置中正確設置,否則會在會話之間丟失數據。 – nmarsh 2015-04-30 14:17:07