Error Creating Chat Room StropheJS with ejabberd

喜欢而已 提交于 2019-12-14 03:44:36

问题


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:


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.



来源:https://stackoverflow.com/questions/31876352/error-creating-chat-room-strophejs-with-ejabberd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!