0
votes

I am running an ejabberd (ver 18.3.0) server with the following config for mod_muc:

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

I am trying to access the muc rooms on this server from various clients (ios with xmppframework, js with node-xmpp-client - crafting the xmpp commands manually). The clients are able to receive messages - ONLY IF I send a presence message after connecting.

However, without sending a presence, I don't receive any messages on the client (even though the subscribe is successful). My understanding was that the presence message is not required to receive messages (for mucsub).

Any help is highly appreciated!


Additional details in response to Badlop's reply

I compared the xml messages on my client/server to the ones you posted. Continuing the user1/user2 example you used, I see a success for user2's subscribe:

<iq xmlns="jabber:client" 
lang="en" 
to="rk3@localhost/abcd" 
from="[email protected]" 
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>

Also, a query of the muc service from user2 results in the below:

<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="[email protected]"/>
</subscriptions>
</iq>

However, when I send a groupchat message from user1:

<message 
from="rk1@localhost" to="[email protected]"
type="groupchat">
<body> hi there777hi there778</body>
</message>

User2 is still not receiving the above message.

I turned on logging level 5 on ejabberd server and can see that the server is trying to send the above message to User2 (rk3). However, the last log I see for this message on the server is below (I don’t see any ‘Send XML on stream’ log for this message).

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

I am probably missing something very basic (w.r.t user / nick / muc room etc) but have no idea what.

Can you please give me the steps you used to create user1/user2, register their nicks etc on the server (using ejabberdctl)?

1

1 Answers

1
votes

My understanding was that the presence message is not required to receive messages (for mucsub).

You're right. There is something strange. So, I've tried myself, and provide you the exact stanzas sent and received, so you can compare, maybe you see something relevant.

You can also try to send those stanzas manually using the XML console of a desktop Jabber client, like Gajim, Psi or Tkabber, so you don't have to write code for this testing.

I configure the module like you do. Then user1 joins room2 (so it gets created). And user2 subscribes to the room:

<iq to='[email protected]'
    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='[email protected]'
    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>

Immediately after that, user1 sends a message to the room, and user2 receives it, without having send any presence stanza.

<message to='user2@localhost/tka1'
    from='[email protected]'>
  <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='[email protected]/user1'
    type='groupchat'
    id='53:939858'
    xmlns='jabber:client'>
          <archived by='[email protected]'
    id='1526291787755131'
    xmlns='urn:xmpp:mam:tmp'/>
          <stanza-id by='[email protected]'
    id='1526291787755131'
    xmlns='urn:xmpp:sid:0'/>
          <body>hi allll</body>
        </message>
      </item>
    </items>
  </event>
</message>

Just to be sure, user2 queries the MUC service the list of his subscriptions, and MUC returns room2, and another one he was also susbscribed:

<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='[email protected]'/>
    <subscription jid='[email protected]'/>
  </subscriptions>
</iq>