powered by Jive Software

Unable to make Persistane muc and Timeout while joining muc room

Welcome to the Smack Developers forums. Please ensure that this is the right venue for your post. As rule of thumb: If you don’t propose also a solution, then please use Smack Support instead.

Hello Team,

I am using smack version 4.2.4 for android for developing muc group. While doing so, I am having issue of two issues.

  1. Unable to create persistence muc room
org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPP error reply received from ggypnsdaqhibyzsu_neurrnqbltsz2tbz_h6ixcttjskcexmky@conference.vbridgesocial.com:XMPPError: bad-request - modify
at org.jivesoftware.smack.StanzaCollector.nextResultOrThrow(StanzaCollector.java:266)
at org.jivesoftware.smack.StanzaCollector.nextResultOrThrow(StanzaCollector.java:217)
at org.jivesoftware.smackx.muc.MultiUserChat.getConfigurationForm(MultiUserChat.java:802)
  1. Timeout Exception while joining muc room.

No response received within reply timeout. Timeout was 10000ms (~10s). Waited for response using: AndFilter: (StanzaTypeFilter: Presence, OrFilter: (AndFilter: (FromMatchesFilter (ignoreResourcepart): 97_9@conference.vbridgesocial.com, MUCUserStatusCodeFilter: status=110), AndFilter: (FromMatchesFilter (full): 97_9@conference.vbridgesocial.com/135, StanzaIdFilter: id=P98q9-46, PresenceTypeFilter: type=error))).

Snippets for create and join chat :

private synchronized MultiUserChat getMultiUserChatConfig(final String room_jid,
                                                              final String room_desc, final boolean shouldConfig) {
        try {

           final MultiUserChat muc = getMultiUserChatManager()
           .getMultiUserChat(JidCreate.entityBareFrom(room_jid));
            esourcepart mResourcepart = Resourcepart.from(nickName);

            if (shouldConfig) {
                muc.create(Resourcepart.from(nickName));
                setConfig(muc, room_desc);
            }

            MucEnterConfiguration.Builder builder = muc.getEnterConfigurationBuilder(mResourcepart);
            Presence subscribe = new Presence(Type.available);
            builder.withPresence(subscribe);

            String roomId = room_jid;
            if (roomId != null && roomId.contains("@")) {
                String replaceService = "@" + SERVICE_MUC;
                roomId = roomId.replace(replaceService, "");
            }

            Contacts contact = AppDatabase.getInstance().getAppDao().getContact(roomId);
            long totalMessage = AppDatabase.getInstance().getAppDao().getTotalMessageFromThis(roomId);


            if (contact != null && totalMessage != 0) {
                int sec = (int) ((TimeUtils.getTimeInMillis() - contact.getLatestMessageDateMillis())
                        / 1000l) - 1;
                builder.requestHistorySince(sec);
            }

            MucEnterConfiguration mucEnterConfiguration = builder.build();

            muc.join(mucEnterConfiguration);

            if (shouldConfig) {
                setConfig(muc, room_desc);
            }

            if (mucMessageListener != null) {
                muc.removeMessageListener(mucMessageListener);
            }
            muc.addMessageListener(mucMessageListener);


            return muc;
        } catch (Exception e) {
            e.printStackTrace();
            isAllGroupJoined = false;

            if (mGroupCreateCallBack != null) {
                mGroupCreateCallBack.onGroupCreateFailed(e.getMessage());
            }

        }
        return null;
    }


    private void setConfig(MultiUserChat multiUserChat, String room_desc) {
        try {
            Form form = multiUserChat.getConfigurationForm();
            Form submitForm = form.createAnswerForm();
            submitForm.setAnswer("muc#roomconfig_roomdesc", room_desc);
            submitForm.setAnswer("muc#roomconfig_roomname", room_desc);
            submitForm.setAnswer("muc#roomconfig_publicroom", true);
            submitForm.setAnswer("muc#roomconfig_persistentroom", true);
            submitForm.setAnswer("muc#roomconfig_membersonly", true);
            multiUserChat.sendConfigurationForm(submitForm);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

Please guide me where I am lacking.
Thanks in advance.

1 Like

Room is not created Persistent when is i am using Smack 4.2.4 version.
Same code is working with Smack 4.2.3 version. I think problem with Samck 4.2.4 version.

1 Like