Openfire does not Synchronize Multi-User-Chat Rooms created by the Rest-API

Hi,

I have 2 Openfire clustered with the Halzelcast-plugin. Additionally I have installed the Rest-API plugin.

So I have this behaviour: If I trigger a multi-user-chat-room create with the RestApi plugin the room is created correctly in the Openfire on which I executed the rest call.

The created group is also available in the second Openfire but it seems that not all properties have been synchronised.

Below I attached some screenshots for the node where I created the room:

And this is a Picture for the Node the secound Node:

It seems that the room is created correctly but after the room is created, some properties are not synchronized via the hazelcast plugin.

If the group gets created via the admin GUI, everything works fine across the whole cluster.

Is this a bug?

Yes, seems to be a bug in REST API

If someone have the same problem. I have overwritten/replaced the create method. I have copied the logic from the muc-room-edit-form.jsp. This works for me but no guarantee Maybe this will help someone…

MUCRoomEntity ob=…;

// Set the new configuration sending an IQ packet with an dataform

FormField field;

XDataFormImpl dataForm = new XDataFormImpl(DataForm.TYPE_SUBMIT);

field = new XFormFieldImpl(“FORM_TYPE”);

field.setType(FormField.TYPE_HIDDEN);

field.addValue(“http://jabber.org/protocol/muc#roomconfig”);

dataForm.addField(field);

field = new XFormFieldImpl(“muc#roomconfig_roomname”);

field.addValue(ob.getNaturalName());

dataForm.addField(field);

field = new XFormFieldImpl(“muc#roomconfig_roomdesc”);

field.addValue(ob.getDescription());

dataForm.addField(field);

field = new XFormFieldImpl(“muc#roomconfig_changesubject”);

field.addValue((!ob.isCanOccupantsChangeSubject()) ? “0” : “1”);

dataForm.addField(field);

field = new XFormFieldImpl(“muc#roomconfig_maxusers”);

field.addValue(ob.getMaxUsers() + “”);

dataForm.addField(field);

field = new XFormFieldImpl(“muc#roomconfig_presencebroadcast”);

if (ob.getBroadcastPresenceRoles().contains(“moderator”)) {

field.addValue(“moderator”);

}

if (ob.getBroadcastPresenceRoles().contains(“participant”)) {

field.addValue(“participant”);

}

if (ob.getBroadcastPresenceRoles().contains(“visitor”)) {

field.addValue(“visitor”);

}

dataForm.addField(field);

field = new XFormFieldImpl(“muc#roomconfig_publicroom”);

field.addValue((!ob.isPublicRoom()) ? “0” : “1”);

dataForm.addField(field);

field = new XFormFieldImpl(“muc#roomconfig_persistentroom”);

field.addValue((!ob.isPersistent()) ? “0” : “1”);

dataForm.addField(field);

field = new XFormFieldImpl(“muc#roomconfig_moderatedroom”);

field.addValue((!ob.isModerated()) ? “0” : “1”);

dataForm.addField(field);

field = new XFormFieldImpl(“muc#roomconfig_membersonly”);

field.addValue((!ob.isMembersOnly()) ? “0” : “1”);

dataForm.addField(field);

field = new XFormFieldImpl(“muc#roomconfig_allowinvites”);

field.addValue((!ob.isCanOccupantsInvite()) ? “0” : “1”);

dataForm.addField(field);

field = new XFormFieldImpl(“muc#roomconfig_passwordprotectedroom”);

field.addValue((ob.getPassword() == null) ? “0” : “1”);

dataForm.addField(field);

field = new XFormFieldImpl(“muc#roomconfig_roomsecret”);

field.addValue(ob.getPassword());

dataForm.addField(field);

field = new XFormFieldImpl(“muc#roomconfig_whois”);

field.addValue(ob.isCanAnyoneDiscoverJID() ? “anyone” : “moderator”);

dataForm.addField(field);

field = new XFormFieldImpl(“muc#roomconfig_enablelogging”);

field.addValue((!ob.isLogEnabled()) ? “0” : “1”);

dataForm.addField(field);

field = new XFormFieldImpl(“x-muc#roomconfig_reservednick”);

field.addValue((!ob.isLoginRestrictedToNickname()) ? “0” : “1”);

dataForm.addField(field);

field = new XFormFieldImpl(“x-muc#roomconfig_canchangenick”);

field.addValue((!ob.isCanChangeNickname()) ? “0” : “1”);

dataForm.addField(field);

field = new XFormFieldImpl(“x-muc#roomconfig_registration”);

field.addValue((!ob.isRegistrationEnabled()) ? “0” : “1”);

dataForm.addField(field);

// Keep the existing list of admins

field = new XFormFieldImpl(“muc#roomconfig_roomadmins”);

for (String jid : ob.getAdmins()) {

field.addValue(new JID(jid).toString());

}

dataForm.addField(field);

// Keep the existing list of owners

field = new XFormFieldImpl(“muc#roomconfig_roomowners”);

// Set owner

JID owner = XMPPServer.getInstance().createJID(“admin”, null);

field.addValue(owner.toString());

dataForm.addField(field);

// update subject before sending IQ (to include subject with cluster

// update)

MUCRoom room = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(“con ference”)

.getChatRoom(ob.getRoomName().toLowerCase(), owner);

if (ob.getSubject() != null) {

// Change the subject of the room by sending a new message

Message message2 = new Message();

message2.setType(Message.Type.groupchat);

message2.setSubject(ob.getSubject());

message2.setFrom(room.getRole().getRoleAddress());

message2.setTo(room.getRole().getRoleAddress());

message2.setID(“local-only”);

room.changeSubject(message2, room.getRole());

}

// Create an IQ packet and set the dataform as the main fragment

IQ iq = new IQ(IQ.Type.set);

Element element = iq.setChildElement(“query”, “http://jabber.org/protocol/muc#owner”);

element.add(dataForm.asXMLElement());

// Send the IQ packet that will modify the room’s configuration

room.getIQOwnerHandler().handleIQ(iq, room.getRole());

Also, when you connect to the openfire server that did NOT create the room, you can see the room if you list them, but you cannot join, like if the room was in locked state. It’s only possible to join if you connect to the openfire that created the room… or if you are the user admin (yes, admin can join if connected to whatever openfire in the cluster)

A workaround I found is to call updateChatRoom() just after calling createChatRoom(). Then everything goes fine. It might seem weird, but maybe this can help fixing the bug.

It also works to login to the console, edit the newly created room and save. After this, you can also join the room if connected to other openfire servers in the cluster.

1 Like

Is this still an issue? I have a similar configuration, using a three node Hazelcast cluster and the REST API for creating/updating users and rooms.

What are createChatRoom() and updateChatRoom() came from?