ejabberd MUC-Sub麻烦

时间:2018-05-14 06:15:54

标签: ejabberd multiuserchat

我正在运行一个ejabberd(版本18.3.0)服务器,其中包含以下mod_muc配置:

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

我正在尝试从各种客户端访问此服务器上的muc房间(ios使用xmppframework,js使用node-xmpp-client - 手动编写xmpp命令)。客户端只能在连接后发送状态消息时才能接收消息。

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

非常感谢任何帮助!

回应Badlop回复的其他详细信息

我将客户端/服务器上的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发送groupchat消息时:

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

User2仍未收到上述消息。

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

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的步骤,在服务器上注册他们的nicks等(使用ejabberdctl)?

1 个答案:

答案 0 :(得分:0)

  

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

你是对的。有一些奇怪的东西。所以,我已经尝试过,并为您提供发送和接收的确切节,因此您可以进行比较,也许您会看到相关内容。

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

我像你一样配置模块。然后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>

在此之后,user1立即向房间发送消息,user2收到消息,而没有发送任何在线节。

<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>