【问题标题】:ejabberd MUC-Sub troubleejabberd MUC-Sub 麻烦
【发布时间】:2018-10-23 17:50:27
【问题描述】:

我正在运行具有以下 mod_muc 配置的 ejabberd(18.3.0 版)服务器:

  mod_muc:
    host: "conference.@HOST@"
    ...
    default_room_options:
      allow_subscription: true
      persistent: true
      mam: true

我正在尝试从各种客户端访问此服务器上的 muc 房间(带有 xmppframework 的 ios,带有 node-xmpp-client 的 js - 手动制作 xmpp 命令)。客户端能够接收消息 - 仅当我在连接后发送 presence 消息时。

但是,如果不发送存在,我不会在客户端收到任何消息(即使订阅 成功)。我的理解是接收消息不需要 presence 消息(对于 mucsub)。

非常感谢任何帮助!


回应巴德洛普回复的更多细节

我将客户端/服务器上的 xml 消息与您发布的消息进行了比较。继续您使用的 user1/user2 示例,我看到 user2 的订阅成功:

<iq xmlns="jabber:client" 
lang="en" 
to="rk3@localhost/abcd" 
from="tr21@conference.localhost" 
type="result" id="D7550060-E2AE-4369-878C-261A02BA48A2">
<subscribe xmlns="urn:xmpp:mucsub:0" nick="rk3n">
<event node="urn:xmpp:mucsub:nodes:messages"/>
<event node="urn:xmpp:mucsub:nodes:presence"/>
</subscribe>
</iq>

另外,来自 user2 的 muc 服务查询结果如下:

<iq xmlns="jabber:client" 
lang="en" 
to="rk3@localhost/abcd" 
from="conference.localhost" type="result" id="B28A237A-5D54-4AE2-821A-195272B05A88">
<subscriptions xmlns="urn:xmpp:mucsub:0">
<subscription jid="tr21@conference.localhost"/>
</subscriptions>
</iq>

但是,当我从 user1 发送群聊消息时:

<message 
from="rk1@localhost" to="tr21@conference.localhost"
type="groupchat">
<body> hi there777hi there778</body>
</message>

User2 仍然没有收到上述消息。

我在 ejabberd 服务器上打开了日志级别 5,可以看到服务器正在尝试将上述消息发送给 User2 (rk3)。但是,我在服务器上看到的这条消息的最后一条日志如下(我没有看到这条消息的任何“Send XML on stream”日志)。

2018-05-14 16:28:57.808 [debug] <0.646.0>@ejabberd_sm:do_route:656 processing message to bare JID:
#message{
 id = <<>>,type = normal,lang = <<>>,
 from =
  #jid{
   user = <<"tr21">>,server = <<"conference.localhost">>,resource = <<>>,
   luser = <<"tr21">>,lserver = <<"conference.localhost">>,lresource = <<>>},
 to =
  #jid{
   user = <<"rk3">>,server = <<"localhost">>,resource = <<>>,
   luser = <<"rk3">>,lserver = <<"localhost">>,lresource = <<>>},
 subject = [],body = [],thread = undefined,
 sub_els =
  [#ps_event{
    items =
     #ps_items{
      xmlns = <<>>,node = <<"urn:xmpp:mucsub:nodes:messages">>,
      items =
       [#ps_item{
         xmlns = <<>>,id = <<"15241958194312511749">>,
         sub_els =
          [#message{
            id = <<>>,type = groupchat,lang = <<"en">>,
            from =
             #jid{
              user = <<"tr21">>,server = <<"conference.localhost">>,
              resource = <<"rk1">>,luser = <<"tr21">>,
              lserver = <<"conference.localhost">>,lresource = <<"rk1">>},
            to =
             #jid{
              user = <<"rk3">>,server = <<"localhost">>,resource = <<>>,
              luser = <<"rk3">>,lserver = <<"localhost">>,lresource = <<>>},
            subject = [],
            body = [#text{lang = <<>>,data = <<"hi there777hi there778">>}],
            thread = undefined,
            sub_els =
             [#mam_archived{
               by =
                #jid{
                 user = <<"tr21">>,server = <<"conference.localhost">>,
                 resource = <<>>,luser = <<"tr21">>,
                 lserver = <<"conference.localhost">>,lresource = <<>>},
               id = <<"1526283878998040">>},
              #stanza_id{
               by =
                #jid{
                 user = <<"tr21">>,server = <<"conference.localhost">>,
                 resource = <<>>,luser = <<"tr21">>,
                 lserver = <<"conference.localhost">>,lresource = <<>>},
               id = <<"1526283878998040">>}],
            meta =
             #{ip => {172,17,0,1},
               mam_archived => true,stanza_id => 1526283878998040}}],
         node = <<>>,publisher = <<>>}],
      max_items = undefined,subid = <<>>,retract = undefined},
    purge = undefined,subscription = undefined,delete = undefined,
    create = undefined,configuration = undefined}],
 meta = #{stanza_id => 1526283879010097}}

我可能遗漏了一些非常基本的东西(w.r.t user / nick / muc room 等),但不知道是什么。

您能否告诉我您在服务器上创建 user1/user2、注册他们的昵称等的步骤(使用 ejabberdctl)?

【问题讨论】:

    标签: ejabberd multiuserchat


    【解决方案1】:

    我的理解是接收消息不需要状态消息(对于 mucsub)。

    你是对的。有什么奇怪的。所以,我自己尝试过,并为您提供发送和接收的确切节,以便您进行比较,也许您会看到相关的内容。

    您也可以尝试使用桌面 Jabber 客户端(如 Gajim、Psi 或 Tkabber)的 XML 控制台手动发送这些节,因此您不必为此测试编写代码。

    我像你一样配置模块。然后 user1 加入 room2 (因此它被创建)。 user2 订阅了房间:

    <iq to='room2@conference.localhost'
        type='set'
        id='E6E10350-76CF-40C6-B91B-1EA08C332FC7'>
      <subscribe xmlns='urn:xmpp:mucsub:0'
                 nick='mynick'
                 password='roompassword'>
        <event node='urn:xmpp:mucsub:nodes:messages' />
        <event node='urn:xmpp:mucsub:nodes:affiliations' />
        <event node='urn:xmpp:mucsub:nodes:subject' />
        <event node='urn:xmpp:mucsub:nodes:config' />
      </subscribe>
    </iq>
    
    <iq xml:lang='es'
        to='user2@localhost/tka1'
        from='room2@conference.localhost'
        type='result'
        id='E6E10350-76CF-40C6-B91B-1EA08C332FC7'>
      <subscribe nick='mynick'
        xmlns='urn:xmpp:mucsub:0'>
        <event node='urn:xmpp:mucsub:nodes:messages'/>
        <event node='urn:xmpp:mucsub:nodes:affiliations'/>
        <event node='urn:xmpp:mucsub:nodes:subject'/>
        <event node='urn:xmpp:mucsub:nodes:config'/>
      </subscribe>
    </iq>
    

    紧接着,用户 1 向房间发送消息,用户 2 收到消息,没有发送任何出席信息节。

    <message to='user2@localhost/tka1'
        from='room2@conference.localhost'>
      <event xmlns='http://jabber.org/protocol/pubsub#event'>
        <items node='urn:xmpp:mucsub:nodes:messages'>
          <item id='1625407893684208871'>
            <message xml:lang='es'
        to='user2@localhost'
        from='room2@conference.localhost/user1'
        type='groupchat'
        id='53:939858'
        xmlns='jabber:client'>
              <archived by='room2@conference.localhost'
        id='1526291787755131'
        xmlns='urn:xmpp:mam:tmp'/>
              <stanza-id by='room2@conference.localhost'
        id='1526291787755131'
        xmlns='urn:xmpp:sid:0'/>
              <body>hi allll</body>
            </message>
          </item>
        </items>
      </event>
    </message>
    

    为了确定,user2 向 MUC 服务查询了他的订阅列表,MUC 返回了 room2,另一个他也订阅了:

    <iq 
        to='conference.localhost'
        type='get'
        id='E6E10350-76CF-40C6-B91B-1EA08C332FC7'>
      <subscriptions xmlns='urn:xmpp:mucsub:0' />
    </iq>
    
    <iq xml:lang='es'
        to='user2@localhost/tka1'
        from='conference.localhost'
        type='result'
        id='E6E10350-76CF-40C6-B91B-1EA08C332FC7'>
      <subscriptions xmlns='urn:xmpp:mucsub:0'>
        <subscription jid='room2@conference.localhost'/>
        <subscription jid='room3@conference.localhost'/>
      </subscriptions>
    </iq>
    

    【讨论】:

    • 非常感谢您的快速回复!
    • 我听取了您的建议并使用 Psi 连接到服务器并分析了 xmpp 消息。事实证明,我没有发送“初始存在”,并且根据 rfc3921,这是强制性的。一旦我发送了初始状态消息,我就能够接收后续消息。非常感谢您的帮助并为我指明正确的方向!
    猜你喜欢
    • 2016-12-09
    • 2017-01-18
    • 1970-01-01
    • 1970-01-01
    • 2017-07-14
    • 2021-03-06
    • 2017-06-29
    • 2017-03-22
    • 1970-01-01
    相关资源
    最近更新 更多