pubsub 发布到节点成功,从节点检索失败

发布于 2024-08-07 05:25:28 字数 2941 浏览 10 评论 0原文

下面显示我建议发布到节点调用“ghost2”,

iq id="kB8dk-0" to="computer/2c10ee6b" type="result"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><jid>admin@computer/Smack</jid></bind></iq>
<iq id="kB8dk-1" to="admin@computer/Smack" type="result"></iq>
<iq id="kB8dk-2" to="admin@computer/Smack" type="result"><query xmlns="jabber:iq:roster"><item jid="test" name="test" subscription="none"></item><item jid="test@computer" subscription="from"></item></query></iq>
<message id="admin@computer__admin@computer__ChWrY" to="admin@computer" from="admin@computer"><event xmlns='http://jabber.org/protocol/pubsub#event'><items node='null'><item id='ghost2'/></items></event></message>
<iq id="kB8dk-4" to="admin@computer/Smack" from="computer" type="result"></iq>
<iq id="kB8dk-5" to="admin@computer/Smack" from="computer" type="result"></iq>
<message id="ghost2__admin@computer__DGaLS" to="admin@computer" from="admin@computer"><event xmlns='http://jabber.org/protocol/pubsub#event'><items node='ghost2'><item id='testid2'><book xmlns="pubsub:test:book"><title>book x</title></book></item></items></event></message>

但是当我尝试从同一节点订阅和检索时,我收到错误 404

<iq id="zpWDI-0" to="computer/b7fe68a8" type="result"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><jid>test@computer/Smack</jid></bind></iq>
<iq id="zpWDI-1" to="test@computer/Smack" type="result"></iq>
<iq id="zpWDI-2" to="test@computer/Smack" type="result"><query xmlns="jabber:iq:roster"><item jid="admin@computer" name="test" subscription="to"><group>Friends</group></item><item jid="test" name="test" subscription="none"></item></query></iq>
<presence id="kB8dk-3" to="test@computer/Smack" from="admin@computer/Smack"></presence>
<message id="admin@computer__test@computer__tAVfB" to="test@computer/Smack" from="admin@computer"><event xmlns='http://jabber.org/protocol/pubsub#event'><items node='TestNode2323'><item id='2Ke42PVQ77iSCP0'><book xmlns="pubsub:test:book"><title>book x</title></book></item></items></event><x xmlns="jabber:x:delay" stamp="20091013T14:16:32"></x><addresses xmlns="http://jabber.org/protocol/address"><address type="replyto" jid="admin@computer/god"/></addresses></message>
<iq id="zpWDI-4" to="test@computer/Smack" from="computer" type="error"><query xmlns="http://jabber.org/protocol/disco#info" node="ghost2"></query><error code="404" type="CANCEL"><item-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>

Below showed i suggest published to node call "ghost2"

iq id="kB8dk-0" to="computer/2c10ee6b" type="result"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><jid>admin@computer/Smack</jid></bind></iq>
<iq id="kB8dk-1" to="admin@computer/Smack" type="result"></iq>
<iq id="kB8dk-2" to="admin@computer/Smack" type="result"><query xmlns="jabber:iq:roster"><item jid="test" name="test" subscription="none"></item><item jid="test@computer" subscription="from"></item></query></iq>
<message id="admin@computer__admin@computer__ChWrY" to="admin@computer" from="admin@computer"><event xmlns='http://jabber.org/protocol/pubsub#event'><items node='null'><item id='ghost2'/></items></event></message>
<iq id="kB8dk-4" to="admin@computer/Smack" from="computer" type="result"></iq>
<iq id="kB8dk-5" to="admin@computer/Smack" from="computer" type="result"></iq>
<message id="ghost2__admin@computer__DGaLS" to="admin@computer" from="admin@computer"><event xmlns='http://jabber.org/protocol/pubsub#event'><items node='ghost2'><item id='testid2'><book xmlns="pubsub:test:book"><title>book x</title></book></item></items></event></message>

but when i try to subsript and retrieve from the same node , i get error 404

<iq id="zpWDI-0" to="computer/b7fe68a8" type="result"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><jid>test@computer/Smack</jid></bind></iq>
<iq id="zpWDI-1" to="test@computer/Smack" type="result"></iq>
<iq id="zpWDI-2" to="test@computer/Smack" type="result"><query xmlns="jabber:iq:roster"><item jid="admin@computer" name="test" subscription="to"><group>Friends</group></item><item jid="test" name="test" subscription="none"></item></query></iq>
<presence id="kB8dk-3" to="test@computer/Smack" from="admin@computer/Smack"></presence>
<message id="admin@computer__test@computer__tAVfB" to="test@computer/Smack" from="admin@computer"><event xmlns='http://jabber.org/protocol/pubsub#event'><items node='TestNode2323'><item id='2Ke42PVQ77iSCP0'><book xmlns="pubsub:test:book"><title>book x</title></book></item></items></event><x xmlns="jabber:x:delay" stamp="20091013T14:16:32"></x><addresses xmlns="http://jabber.org/protocol/address"><address type="replyto" jid="admin@computer/god"/></addresses></message>
<iq id="zpWDI-4" to="test@computer/Smack" from="computer" type="error"><query xmlns="http://jabber.org/protocol/disco#info" node="ghost2"></query><error code="404" type="CANCEL"><item-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

厌味 2024-08-14 05:25:28

您已收到已发布的项目:

<book xmlns="pubsub:test:book"><title>book x</title></book>

您已收到来自“计算机”(您的 xmpp 服务器)针对此查询的 404 错误:

<query xmlns="http://jabber.org/protocol/disco#info" node="ghost2"></query>

这与服务发现有关。您是否有可能从完整的对话中删除了一些消息?

编辑:

你可以尝试用

PubSubManager manager = new PubSubManager(connection, "computer");

这个替换:

String pubSubAddress = "pubsub." + connection.getServiceName();
PubSubManager manager = new PubSubManager(connection, pubSubAddress);

You've received the published item:

<book xmlns="pubsub:test:book"><title>book x</title></book>

You've received the 404 error from "computer" (your xmpp server) for this query:

<query xmlns="http://jabber.org/protocol/disco#info" node="ghost2"></query>

Which hast to do with service discovery. Is it possible that you've removed some messages from the complete conversation?

Edit:

Could you try to replace:

PubSubManager manager = new PubSubManager(connection, "computer");

with this

String pubSubAddress = "pubsub." + connection.getServiceName();
PubSubManager manager = new PubSubManager(connection, pubSubAddress);
人海汹涌 2024-08-14 05:25:28

也许这个例子可以作为你的参考:

public void login(String Ip,String username,String passwaord)
     {
         try 
         {
            connConfig = new AndroidConnectionConfiguration(Ip, 5222);
            connection = new XMPPConnection(connConfig);
            connection.connect();  
            connection.login(username, passwaord);
            pubSubAddress = "pubsub."+ connection.getServiceName();
            manager = new PubSubManager(connection,pubSubAddress);
            Log.i("MyError","connection success");  
         }
         catch (XMPPException e) 
         {
             Log.i("MyError","connection failed");      
             e.printStackTrace();
         }

     }

另外,你可以参考另一个与您的问题相关的问题

希望这会有所帮助。

Maybe this example can be used as a reference for you:

public void login(String Ip,String username,String passwaord)
     {
         try 
         {
            connConfig = new AndroidConnectionConfiguration(Ip, 5222);
            connection = new XMPPConnection(connConfig);
            connection.connect();  
            connection.login(username, passwaord);
            pubSubAddress = "pubsub."+ connection.getServiceName();
            manager = new PubSubManager(connection,pubSubAddress);
            Log.i("MyError","connection success");  
         }
         catch (XMPPException e) 
         {
             Log.i("MyError","connection failed");      
             e.printStackTrace();
         }

     }

In addition, you may refer to another question which is relevant to yours.

Hope this will help.

時窥 2024-08-14 05:25:28

也许你可以参考这个例子:

import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smackx.pubsub.ItemPublishEvent;
import org.jivesoftware.smackx.pubsub.Node;
import org.jivesoftware.smackx.pubsub.PayloadItem;
import org.jivesoftware.smackx.pubsub.PubSubManager;
import org.jivesoftware.smackx.pubsub.listener.ItemEventListener;
public class XmppPubsub_Reciever {
    private static XMPPConnection connection = new XMPPConnection("think");
    private static String USRE_NAME = "user";
    private static String PASSWORD = "1";
    static {
        try {
            connection.connect();
            connection.login(USRE_NAME, PASSWORD);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public static void main(String[] args) throws Exception {
        String nodeId = "test";
        PubSubManager manager = new PubSubManager(connection);
        Node eventNode = manager.getNode(nodeId);
        eventNode.addItemEventListener(new ItemEventListener<PayloadItem>() {
            public void handlePublishedItems(ItemPublishEvent evt) {
                for (Object obj : evt.getItems()) {
                    PayloadItem item = (PayloadItem) obj;
                    System.out.println("--:Payload=" + item.getPayload().toString());
                }
            }
        });
        eventNode.subscribe(connection.getUser());
        while(true);
    }
}

Maybe you can refer to this example:

import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smackx.pubsub.ItemPublishEvent;
import org.jivesoftware.smackx.pubsub.Node;
import org.jivesoftware.smackx.pubsub.PayloadItem;
import org.jivesoftware.smackx.pubsub.PubSubManager;
import org.jivesoftware.smackx.pubsub.listener.ItemEventListener;
public class XmppPubsub_Reciever {
    private static XMPPConnection connection = new XMPPConnection("think");
    private static String USRE_NAME = "user";
    private static String PASSWORD = "1";
    static {
        try {
            connection.connect();
            connection.login(USRE_NAME, PASSWORD);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public static void main(String[] args) throws Exception {
        String nodeId = "test";
        PubSubManager manager = new PubSubManager(connection);
        Node eventNode = manager.getNode(nodeId);
        eventNode.addItemEventListener(new ItemEventListener<PayloadItem>() {
            public void handlePublishedItems(ItemPublishEvent evt) {
                for (Object obj : evt.getItems()) {
                    PayloadItem item = (PayloadItem) obj;
                    System.out.println("--:Payload=" + item.getPayload().toString());
                }
            }
        });
        eventNode.subscribe(connection.getUser());
        while(true);
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文