XMPP:Ejabberd 未将具有命名空间前缀的自定义 IQ 转发给用户

Posted

技术标签:

【中文标题】XMPP:Ejabberd 未将具有命名空间前缀的自定义 IQ 转发给用户【英文标题】:XMPP: Ejabberd not forwarding custom IQ with namespace prefix to user 【发布时间】:2013-09-11 12:52:11 【问题描述】:

我必须使用我自己的命名空间 http://www.test.com/testeva@pc377/Smack 向特定用户 bob@pc377/Smack 发送自定义 IQ。当我使用 OpenFire 时一切正常,但 Ejabberd 不会将此 IQ 转发给用户。在我看到的日志文件中,IQ 由服务器接收,内部分派给会话管理器,但未转发给用户。如果我发送Message,它会被正确转发。我正在使用基于 Java 的 Smack-Client。

Ejabberd 是否需要特定配置来转发自定义 IQ?

    =INFO REPORT==== 2013-09-11 13:55:36 ===
    D(<0.658.0>:ejabberd_receiver:320) : Received XML on stream = 
    "<iq id=\"0j8w6-8\" to=\"bob@pc377/Smack\" type=\"set\">
        <ts:register-request xmlns:ts=\"http://www.test.com/test\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">
           <ts:node-id>550e8400-e29b-11d4-a716-446655440000</ts:node-id>
           <ts:properties>
              <ts:path>.</ts:path>
              <ts:delivery-mode>1</ts:delivery-mode>
           </ts:properties>
       </ts:register-request>
    </iq>"


    =INFO REPORT==== 2013-09-11 13:55:36 ===
    D(<0.659.0>:ejabberd_router:313) : route
from jid,"eva","pc377","Smack","eva","pc377","Smack"
to jid,"bob","pc377","Smack","bob","pc377","Smack"
packet xmlelement,"iq",
               ["id","0j8w6-8",
                "to","bob@pc377/Smack",
                "type","set"],
               [xmlelement,"ts:register-request",
                    ["xmlns:ts","http://www.test.com/test",
                     "xmlns:xs","http://www.w3.org/2001/XMLSchema",
                     "xmlns:xsi",
                      "http://www.w3.org/2001/XMLSchema-instance"],
                    [xmlelement,"ts:node-id",[],
                         [xmlcdata,
                              <<"550e8400-e29b-11d4-a716-446655440000">>],
                     xmlelement,"ts:properties",[],
                         [xmlelement,"ts:path",[],[xmlcdata,<<".">>],
                          xmlelement,"ts:delivery-mode",[],
                              [xmlcdata,<<"1">>]]]]


    =INFO REPORT==== 2013-09-11 13:55:36 ===
    D(<0.659.0>:ejabberd_local:300) : local route
from jid,"eva","pc377","Smack","eva","pc377","Smack"
to jid,"bob","pc377","Smack","bob","pc377","Smack"
packet xmlelement,"iq",
                       ["id","0j8w6-8","to",[...],[...],...],
                       [xmlelement,[...],...]


    =INFO REPORT==== 2013-09-11 13:55:36 ===
    D(<0.659.0>:ejabberd_sm:411) : session manager
from jid,"eva","pc377","Smack","eva","pc377","Smack"
to jid,"bob","pc377","Smack","bob","pc377","Smack"
packet xmlelement,"iq",
                       ["id","0j8w6-8","to",[...],[...],...],
                       [xmlelement,[...],...]


    =INFO REPORT==== 2013-09-11 13:55:36 ===
    D(<0.659.0>:ejabberd_sm:510) : sending to process <0.656.0>

【问题讨论】:

【参考方案1】:

用更简单的 XML 试试:

<iq id="0j8w6-8" to="bob@pc377/Smack" type="set">
    <register-request xmlns="http://www.test.com/test">
       <node-id>550e8400-e29b-11d4-a716-446655440000</node-id>
       <properties>
          <path>.</path>
          <delivery-mode>1</delivery-mode>
       </properties>
   </register-request>
</iq>

如果这不起作用,请尝试重命名 register-requestdelivery-mode 以删除破折号。这些更改都不是必需的,但任何一个都可以帮助 ejabberd 团队找到错误。

【讨论】:

好建议...我试过了,智商转发!经过一些测试,在我看来 ejabberd 无法处理 XML 中的命名空间前缀。 我已经提交了一个错误报告。可以在这里找到:support.process-one.net/i#browse/EJAB-1661

以上是关于XMPP:Ejabberd 未将具有命名空间前缀的自定义 IQ 转发给用户的主要内容,如果未能解决你的问题,请参考以下文章

基于多部分 xml 根声明创建具有命名空间前缀的元素

需要命名空间管理器或 XsltContext。此查询具有前缀、变量或用户定义的函数

不允许任何所有者撤销创建房间/MUC 的用户的所有权 - Ejabberd XMPP

XMPP 流量记录 (ejabberd 13.12)

如何避免 GDB 中符号的命名空间前缀?

带有命名空间前缀的 TagSoup 属性