androidxmppejabberdsmackgroupchat

Getting MucConfigurationNotSupportedException In android smack 4.2.0-beta1


I am developing chat application for one to one chat and group chat.

I have successfully done one to one chat.

Using the below link I have created Group chat.

Link to create Group chat in smack 4.2.0-beta1

I can see the group in admin panel but There is only a single user available, But I have created this group with three members. Here I have added my code.

 public void createGroupChat() {

        String DomainName = "conference."+ServiceAddress;
        // Create a MultiUserChat using a Connection for a room
// Get the MultiUserChatManager
        MultiUserChatManager manager = MultiUserChatManager.getInstanceFor(connection);
        try {
            EntityBareJid jid = JidCreate.entityBareFrom("mychatroom3" + "@"
                    + DomainName);

// Create a MultiUserChat using an XMPPConnection for a room
            MultiUserChat muc = manager.getMultiUserChat(jid);

// Prepare a list of owners of the new room
            Set<Jid> owners = JidUtil.jidSetFrom(new String[]{"admin" + "@"
                    + DomainName, "dev1" + "@"
                    + DomainName, "dev2" + "@"
                    + DomainName});

// Create the room
            Resourcepart nickname = Resourcepart.from("admin");
            muc.create(nickname).getConfigFormManager().setRoomOwners(owners).submitConfigurationForm();
            muc.join(nickname);
            Log.e("Group chat", "Created");
            Toast.makeText(context,
                    "Group chat" + "Created",
                    Toast.LENGTH_SHORT).show();
        } catch (XmppStringprepException e) {
            e.printStackTrace();
        } catch (MultiUserChatException.MucAlreadyJoinedException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (XMPPException.XMPPErrorException e) {
            e.printStackTrace();
        } catch (MultiUserChatException.MissingMucCreationAcknowledgeException e) {
            e.printStackTrace();
        } catch (NotConnectedException e) {
            e.printStackTrace();
        } catch (SmackException.NoResponseException e) {
            e.printStackTrace();
        } catch (MultiUserChatException.NotAMucServiceException e) {
            e.printStackTrace();
        } catch (MultiUserChatException.MucConfigurationNotSupportedException e) {
            e.printStackTrace();
        }
    }

Exception that I got

08-01 05:58:14.589 917-917/com.agarangroup.hello W/System.err: org.jivesoftware.smackx.muc.MultiUserChatException$MucConfigurationNotSupportedException: The MUC configuration 'muc#roomconfig_roomowners' is not supported by the MUC service
08-01 05:58:14.590 917-917/com.agarangroup.hello W/System.err:     at org.jivesoftware.smackx.muc.MucConfigFormManager.setRoomOwners(MucConfigFormManager.java:137)
08-01 05:58:14.590 917-917/com.agarangroup.hello W/System.err:     at com.agarangroup.hello.Services.MyXMPP.createGroupChat(MyXMPP.java:331)
08-01 05:58:14.590 917-917/com.agarangroup.hello W/System.err:     at com.agarangroup.hello.slidingtab.chats.GroupChatActivity.onCreate(GroupChatActivity.java:99)

Solution

  • There are 2 cases: 1) Your conference service does not supports owners (depends by server, Ejabber in your case, and this doesn't sounds normal)

    2) Your config form it's not completed as documentation says and you need to create a full form.

    How to fix: substitute this line:

     muc.create(nickname).getConfigFormManager().setRoomOwners(owners).submitConfigurationForm();
    

    with:

    muc.create(nickname);
    Form form = muc.getConfigurationForm().createAnswerForm();
    form.setAnswer("muc#roomconfig_roomowners", owners);
    muc.sendConfigurationForm(form); 
    

    pay attention to names:

    your DomainName it's the Service conference name + Server Domain Name. An owner can be a JID (foo@myserver) and not related on service (so foo@service.myserver it's not a valid user, even if server will accept it).

    Fix your owners with:

    "admin" + "@" + ServiceAddress, "dev1" + "@" + ServiceAddress, "dev2" + "@" + ServiceAddress