0

I am using Smack 4.1.1 as Gradle dependency in mine Android project.

I have successfully established connection with mine local OpenFire server.

But I have an issue while creating temporary room from Android client.

final MultiUserChat multiUserChat = userChatManager.getMultiUserChat(roomId);  
    try {  
        multiUserChat.create(connection.getUser());  
        LOG.debug("room created");  
    } catch (XMPPException.XMPPErrorException | SmackException e) {  
        LOG.error("create room error:{}", e);  
    }  
    try{  
        multiUserChat.sendConfigurationForm(new Form(DataForm.Type.submit));   
    } catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | SmackException.NotConnectedException e) {  
        LOG.error("sending room configurations error:{}", e);  
    }   

The most great thing is that I can see that room was created in OpenFire admin panel and get room information from another client.

try {  
    MultiUserChatManager userChatManager = MultiUserChatManager.getInstanceFor(connection);  
    RoomInfo info = userChatManager.getRoomInfo(roomId);  
    LOG.debug("room has {} occupants", info.getOccupantsCount());  
    joinToExistingRoom(roomId);  
} catch (XMPPException.XMPPErrorException e) {  
    LOG.error("join room error:{}", e);  
    final XMPPError.Condition condition = e.getXMPPError().getCondition();  
    if (condition == XMPPError.Condition.item_not_found) {  
        LOG.error("room does not exist error:{}", e);  
        createRoom(roomId);  
    }  
}  

But while trying to join room from second client I receive XMPPError: recipient-unavailable - wait.

Snippet of mine joinRoom method:

final MultiUserChat multiUserChat = userChatManager.getMultiUserChat(roomId);  
    try {  
        multiUserChat.join(connection.getUser());  
        LOG.debug("joined to room:{}", roomId);  
    } catch (SmackException.NoResponseException  
                | XMPPException.XMPPErrorException  
                | SmackException.NotConnectedException e) {  
        LOG.error("error joining room {}", e);  
    }  

So I am catching error joining room org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPPError:recipient-unavailable - wait

So the question is what can be wrong? I also tried creating submitForm from createAnswerForm() method. But the result is the same.

One solution I have found to make it work is to send persistantroom as true in Answer of configuration form. But this method creates persistent room, though I need this room to be destroyed after all attendees leave room.

Maybe it is a simple problem, but now I do not know how to solve this issue.

Help will be appreciated a lot.

Thanks in advance.

Flow
  • 23,572
  • 15
  • 99
  • 156
BAZTED
  • 546
  • 5
  • 16

1 Answers1

1

The create() method documentation states that:

Creates the room according to some default configuration, assign the requesting user as the room owner, and add the owner to the room but not allow anyone else to enter the room (effectively "locking" the room). The requesting user will join the room under the specified nickname as soon as the room has been created. To create an "Instant Room", that means a room with some default configuration that is available for immediate access, the room's owner should send an empty form after creating the room.

Try to send configuration form this way:

multiUserChat.create(connection.getUser())
Form form = new Form(DataForm.Type.submit);
multiUserChat.sendConfigurationForm(form);

See also muc extension documentation

bardi
  • 373
  • 5
  • 17