New user registration Openfire server return bad-request stanzas

I am trying to register a new user with aSmack 4 using this code:

ConnectionConfiguration config = new ConnectionConfiguration(Constant.XMPP_HOST, Constant.XMPP_PORT);
SASLAuthentication.supportSASLMechanism("PLAIN", 0);
config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
Roster.setDefaultSubscriptionMode(Roster.SubscriptionMode.accept_all);
conn2 = new XMPPTCPConnection(config);

String user ="bear";
String pass = "123";
String email = "bear@bear.com";
HashMap<String,String> attr = new HashMap<String, String>();
attr.put("username",user);
attr.put("password",pass);
attr.put("email", email);
if(conn2!=null) {

Registration reg = new Registration();
reg.setType(IQ.Type.SET);
reg.setTo(conn2.getServiceName());
reg.setAttributes(attr);
PacketFilter filter = new AndFilter(new PacketIDFilter(
        reg.getPacketID()), new PacketTypeFilter(IQ.class));
PacketCollector collector = conn2 .createPacketCollector(filter);
try {
    conn2.sendPacket(reg);
} catch (SmackException.NotConnectedException e) {
    e.printStackTrace();
}
IQ result = (IQ) collector.nextResult(SmackConfiguration
        .getDefaultPacketReplyTimeout());
System.out.println(result);
collector.cancel(); 

      

But the Openfire server is returning this packet and I don't know what that means.

<iq id='XILKN-9' to='pc-pc/b529612d' from='192.168.21.107' type='error'>
      <query xmlns='jabber:iq:register'>
          <password>123</password>
          <email>bear@bear.com</email>
          <username>bear</username>
     </query>
     <error type="modify">
          <bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
    </error>
</iq>

      

What's the problem? I am using OpenFire 3.9.3 and aSmack 4.0.7.

+3


source to share


1 answer


I know this is too late, but hope this helps someone. In the connection configuration, make sure you are setServiceName

correct. Ieconfig.setServiceName(Name of your service);



0


source







All Articles