AnsweredAssumed Answered

Bad Request When Register to Openfire using smack 4.0.1 in android

Question asked by dharmesh on Jun 15, 2016

I have written a following code to register a new anonymous user using smack in android.

 

public void createNewAccount() {

  AccountManager accountManager = AccountManager.getInstance(mConnection);

   if (accountManager != null) {

  Log.d("Account manager", "NOT NULL");

  accountManager.sensitiveOperationOverInsecureConnection(true);

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

  attr.put("username", loginUser);

  attr.put("password", passwordUser);

  attr.put("email", loginUser);

   try {

  accountManager.createAccount(loginUser, passwordUser, attr);

   accountCreated = true;

  } catch (SmackException.NoResponseException e) {

  e.printStackTrace();

  } catch (XMPPException.XMPPErrorException e) {

  e.printStackTrace();

  } catch (NotConnectedException e) {

  e.printStackTrace();

  }

  } else {

  Log.d("Account manager", "NULL");

  }

}

 

I am getting following error.

 

06-15 15:53:27.332 2026-10349/com.dsquare.dchat I/System.out: 03:53:27 PM SENT (0): <iq to='192.168.0.250' id='IAX28-1' type='set'><query xmlns='jabber:iq:register'><email>dharmesh1</email><password>dharmesh1</passwor d><username>dharmesh1</username></query></iq>

06-15 15:53:27.364 2026-10350/com.dsquare.dchat I/System.out: 03:53:27 PM RECV (0): <iq type="error" id="IAX28-1" from="192.168.0.250" to="divyang-pc/9f351hyo93"><query xmlns="jabber:iq:register"><email>dharmesh1</email><password>dharmesh1</passwor d><username>dharmesh1</username></query><error code="400" type="modify"><bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>

06-15 15:53:27.440 2026-10348/com.dsquare.dchat W/System.err: org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPPError: bad-request - modify

06-15 15:53:27.468 2026-10348/com.dsquare.dchat W/System.err:     at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:2 32)

06-15 15:53:27.496 2026-10348/com.dsquare.dchat W/System.err:     at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:2 13)

06-15 15:53:27.508 2026-10348/com.dsquare.dchat W/System.err:     at org.jivesoftware.smackx.iqregister.AccountManager.createAccount(AccountManager. java:272)

06-15 15:53:27.512 2026-10348/com.dsquare.dchat W/System.err:     at com.dsquare.xmppservices.XMPPConnection$XMPPConnectionListener.connected(XMPPCo nnection.java:989)

06-15 15:53:27.528 2026-10348/com.dsquare.dchat W/System.err:     at org.jivesoftware.smack.AbstractXMPPConnection.callConnectionConnectedListener(A bstractXMPPConnection.java:1152)

06-15 15:53:27.532 2026-10348/com.dsquare.dchat W/System.err:     at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectInternal(XMPPTCPConnection. java:841)

06-15 15:53:27.544 2026-10348/com.dsquare.dchat W/System.err:     at org.jivesoftware.smack.AbstractXMPPConnection.connect(AbstractXMPPConnection.ja va:360)

06-15 15:53:27.548 2026-10348/com.dsquare.dchat W/System.err:     at com.dsquare.xmppservices.XMPPConnection$2.doInBackground(XMPPConnection.java:25 2)

06-15 15:53:27.552 2026-10348/com.dsquare.dchat W/System.err:     at com.dsquare.xmppservices.XMPPConnection$2.doInBackground(XMPPConnection.java:23 4)

06-15 15:53:27.560 2026-10348/com.dsquare.dchat W/System.err:     at android.os.AsyncTask$2.call(AsyncTask.java:287)

06-15 15:53:27.564 2026-10348/com.dsquare.dchat W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:234)

06-15 15:53:27.568 2026-10348/com.dsquare.dchat W/System.err:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)

06-15 15:53:27.576 2026-10348/com.dsquare.dchat W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)

06-15 15:53:27.580 2026-10348/com.dsquare.dchat W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)

06-15 15:53:27.584 2026-10348/com.dsquare.dchat W/System.err:     at java.lang.Thread.run(Thread.java:841)

Outcomes