1
votes

I am trying to create a instant chat room using Smack but the server returns me an IQ packet with an error code 401 and type="AUTH" and a message packet with a message that the room is locked from entry until configuration is confirmed

final MultiUserChat muc = new MultiUserChat(connection, chatName+"@conference.123");
try {
     muc.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));
     muc.create(chatName);
     } catch (XMPPException e) {
        Log.e("Exception", e.getMessage());
     }

This gives an exception (not-authorized(401)). Following are the two packets received from server:

<iq id="J1O5y-5" to="akshay@123/Smack" from="[email protected]" type="error"><error code="401" type="AUTH"><not-authorized xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>

and

<message to="akshay@123/Smack" from="[email protected]" type="groupchat"><body>This room is locked from entry until configuration is confirmed.</body></message>

So are there any changes in server configuration that I need to make or is there any problem in code ?

2

2 Answers

0
votes

How about changing the order as below:

muc.create(nickName);
muc.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));

Hope this will help :)

0
votes

It worked for me. Please try this.

public void createRoom(String r,String n) throws XMPPException {
    // TODO Auto-generated method stub
    String t = r + "@conference.localhost";

    MultiUserChat muc = new MultiUserChat(connection, t);

    muc.create(n);

    muc.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));

}