【问题标题】:Not Authorized error while creating a MultiUserChat room创建 MultiUserChat 房间时出现未授权错误
【发布时间】:2013-10-21 07:10:41
【问题描述】:

我正在尝试使用 Smack 创建一个即时聊天室,但服务器返回给我一个带有错误代码 401 和 type="AUTH" 的 IQ 数据包和一个消息数据包,其中包含一个消息,即房间已被锁定,直到配置完成确认

final MultiUserChat muc = new MultiUserChat(connection, chatName+"@conference.123");
try {
     muc.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));
     muc.create(chatName);
     } catch (XMPPException e) {
        Log.e("Exception", e.getMessage());
     }

这给出了一个例外(未授权(401))。 以下是从服务器收到的两个数据包:

<iq id="J1O5y-5" to="akshay@123/Smack" from="test@conference.123" type="error"><error code="401" type="AUTH"><not-authorized xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>

<message to="akshay@123/Smack" from="test@conference.123" type="groupchat"><body>This room is locked from entry until configuration is confirmed.</body></message>

那么我需要对服务器配置进行任何更改还是代码有任何问题?

【问题讨论】:

    标签: xmpp smack asmack multiuserchat


    【解决方案1】:

    如何改变顺序如下:

    muc.create(nickName);
    muc.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));
    

    希望这会有所帮助:)

    【讨论】:

      【解决方案2】:

      它对我有用。请试试这个。

      public void createRoom(String r,String n) throws XMPPException {
          // TODO Auto-generated method stub
          String t = r + "@conference.localhost";
      
          MultiUserChat muc = new MultiUserChat(connection, t);
      
          muc.create(n);
      
          muc.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));
      
      }
      

      【讨论】:

        猜你喜欢
        • 2016-10-18
        • 1970-01-01
        • 1970-01-01
        • 2021-12-29
        • 1970-01-01
        • 2012-03-07
        • 1970-01-01
        • 2017-01-19
        • 2021-09-08
        相关资源
        最近更新 更多