8
votes

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();
            }
2

2 Answers

11
votes

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.

0
votes

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.