8

Am using the Xabber open source project and am able to create a new group, But it always says: This room is locked from entry until configuration is confirmed. I tried to set a default configuration but it throws me exception: 401 not authorized. Whats exactly the problem.

final MultiUserChat multiUserChat;
        try {
            multiUserChat = new MultiUserChat(xmppConnection, room);
            // CHANAKYA: set default config for the MUC
            // Send an empty room configuration form which indicates that we want
            // an instant room
            try {
                multiUserChat.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));
            } catch (XMPPException e) {
                e.printStackTrace();
            }
sukarno
  • 597
  • 2
  • 10
  • 31

2 Answers2

11

I was also facing the same error. Here I modified the code and it's work for me. Error 401 is not authorized error when we are calling the any getConfigurationForm(), without joining it.


multiUserChat.join(nickname, password);
setConfig(multiUserChat); // Here I am calling submit form

private void setConfig(MultiUserChat multiUserChat) {

    try {
        Form form = multiUserChat.getConfigurationForm();
        Form submitForm = form.createAnswerForm();
        for (Iterator<FormField> fields = submitForm.getFields(); fields
                .hasNext();) {
            FormField field = (FormField) fields.next();
            if (!FormField.Type.hidden.equals(field.getType())
                    && field.getVariable() != null) {
                submitForm.setDefaultAnswer(field.getVariable());
            }
        }
        submitForm.setAnswer("muc#roomconfig_publicroom", true);
        submitForm.setAnswer("muc#roomconfig_persistentroom", true);
        multiUserChat.sendConfigurationForm(submitForm);
    } catch (Exception e) {
        e.printStackTrace();
    }

}

And now I am able to successfully submit the form without any exception. Hope this will work for you.

Muhammed Fasil
  • 7,909
  • 2
  • 19
  • 28
u_pendra
  • 908
  • 1
  • 10
  • 25
0

You must have permissions to set the configuration. This can usually be changed in the server settings. If you have Openfire for example you should go to Group Chat>Group chat settings>Click your Group Chat service>Room Creation Permissions or Administrators.

You are probably unable to change this client side, it's only possible if you have access to the server you are trying to connect to.

koesie10
  • 572
  • 4
  • 17
  • Hi koesie thanks for the reply, i tried changing the Room creation permission to everyone and also i added my jabber id to the Aminstrators list. But still when i create a new group i get the same error. – sukarno Jun 05 '13 at 11:37