Error Creating Chat Room StropheJS with ejabberd

2019-06-11 02:52发布

I am trying to create a chat room using StropheJS

My Code:

var presence = $pres({ to:  "testRoom@conference@localhost/yashwanth, from: Strophe.getBareJidFromJid(connection.jid) });
     Groupie.connection.send( presence.tree());
    Groupie.connection.muc.createInstantRoom("testRoom@conference.localhost/yashwanth",
      function(status) {
        console.log("Room Created Successfully", status);
      },
      function(status) {
        console.log("Error Creating Room", status);
      });

While creating the room I am facing the below error.

I found that the roomJID should be in the format of room_name@conference@HOST@/nickname . So as per the format i send that. But it doesn't create the room.

Error Creating Room <iq xmlns=​"jabber:​client" from=​
"conference@conference.localhost" to=​"yashwanth@inst1.eab.com/​
5441440311438943022710601" type=​"error" id=​"1:​sendIQ">​<query xmlns=​"http:​/​/​
jabber.org/​protocol/​muc#owner">​…​</query>​<error code=​"404" type=​"cancel">​
<item-not-found xmlns=​"urn:​ietf:​params:​xml:​ns:​xmpp-stanzas">​</item-not-
found>​<text xmlns=​"urn:​ietf:​params:​xml:​ns:​xmpp-stanzas">​Conference room 
does not exist​</text>​</error>​</iq>

And I am using ejabberd as my XMPP server. If the room creates then in which database able the details related to the room will be saved? Either it save in muc_registered table or muc_room table?

1条回答
狗以群分
2楼-- · 2019-06-11 03:43

To join a room in XMPP, you do not need to create it first.

What your code is doing is:

  1. It sends the presence to the room, meaning that you are joining it. If it does not exist it will be created.
  2. You try creating the room, which should always fails as the room always exists.
  3. You are asking where room is stored. It is not stored unless it is persistent, which is not the case in your example if you did not configure ejabberd to set default room options to persistent. Otherwise you need to edit room options as defined in XEP-0045 Multi User Chat to make it persistent. Persistent rooms are stored in Mnesia table muc_room.
  4. createInstantRoom in StropheJS MUC plugin create room with default options, just like joining so I do not see why it would be needed here.

So, I cannot tell what you are trying to achieve with your code, but just send the presence to the room is enough to create a non-persistent chat room and join it. No need to call createInstantRoom.

查看更多
登录 后发表回答