Smack 4.1.1 accountManager createAccont gets 400 error?

Hi all,

I’m newbie of samck,and try to use smack 4.1.1 in my android project,I’ve did a little bit test about login exist user and sending message,everything seems ok.

but when i tried to use accountManager to create a new account,the createAccount func thrown an error: “bad-request-modify” if no existed user login at the first place.

I don’t know if i did something wrong.Can anyone help? thanks any way.

code likes this:

XMPPTCPConnectionConfiguration config …//

 .......

 mConnection = new XMPPTCPConnection(config);

 mConnection.connect();//mConnect.isConnected == true

 //mConnection.login("test1", "111111");  //test1 is exist,createAccount goes fine if uncomment this line otherwise createAccount  throws "bad-request-modify"

 AccountManager accountManager= AccountManager.getInstance(mConnection);
 accountManager.sensitiveOperationOverInsecureConnection(true);
 accountManager.createAccount("test2", "111111",mp);

Please, report the stack of the console so we can see the errors
I paste a cut of mine class of registration:


XMPPTCPConnectionConfiguration connectionConfig = XMPPTCPConnectionConfiguration.builder()

.setServiceName(DB_Conn.SERVICE_NAME)

.setHost(DB_Conn.HOST)

.setConnectTimeout(200000)

.setSendPresence(false)

.setPort(DB_Conn.PORT)

.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)

.build();

XMPPTCPConnection connection = new XMPPTCPConnection(connectionConfig);

try {

connection.connect();

AccountManager accountManager = AccountManager.getInstance(connection);

Map<String, String> map = new HashMap<String, String>();

map.put(“username”, username);

map.put(“name”, name);

map.put(“password”, password);

map.put(“email”, email);

map.put(“creationDate”, “”+System.currentTimeMillis() / 1000L);

accountManager.createAccount(username, password, map);

} catch (Exception e) {

e.printStackTrace();

return “error”;

}

return “done”;

Note1: see that username,name,password,email are variable that had the value of the text of the relative edittext. Hope it will help you
Note2: try to connect without setUsernameAndPassword() parameter of builder. Of course, you have to set the setting on openfire that you allow users to register.

1 Like

Thanks for the reply:

the debug log seems a little mess

//////

D/SMACK﹕ SENT (0): <stream:stream xmlns=‘jabber:client’ to=‘192.168.0.107’ xmlns:stream=‘http://etherx.jabber.org/streams’ version=‘1.0’ xml:lang=‘en’>

D/SMACK﹕ RECV (0): <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream=“http://etherx.jabber.org/streams” xmlns=“jabber:client” from=“hbo” id=“2888d3a0” xml:lang=“en” version=“1.0”>

D/SMACK﹕ RECV (0): stream:featuresPLAIN</mechanis ms>zlib</stream:features>

D/SMACK﹕ SENT (0): 1434464881tes t1asd@163.com111111test1

D/SMACK﹕ RECV (0): 1434464881tes t1asd@163.com111111test1 **E/Error:﹕ org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPPError: bad-request - modify **

///////

I wonder if it involve the server system property setting (openfire).

I’ve added such property.

sasl.mechs

PLAIN

1 Like

Anybody can help with this issue?

@hubo was you able to fix this?

I tried code suggested by Stefeno and finally able to solve problem after digging out server code. Problem was in client config(Smack SDK) before we connect to openfire.

I was passing incorrect service name in XMPPTCPConnectionConfiguration.setServiceName() which caused packets drops in IQRouter as client is not authenticated yet. Hope this helps someone!!

2 Likes