简体   繁体   中英

openfire issue using smack 4.1.0 on android

Iam making an IM client on android. Iam using an instance of openfire server running on EC2. I am currently trying to register a new user with my app. the connection works fine but when I call AccountManager.createAccount(email, password, mymap) Iam getting an exception.

namely a XMPPErrorExecption below is my stack trace

10-01 02:58:54.443    1747-3673/com.example.eoin_a.im_app20 W/System.err﹕ org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPPError: bad-request - modify
10-01 02:58:54.444    1747-3673/com.example.eoin_a.im_app20 W/System.err﹕ at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:232)
10-01 02:58:54.444    1747-3673/com.example.eoin_a.im_app20 W/System.err﹕ at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:213)
10-01 02:58:54.444    1747-3673/com.example.eoin_a.im_app20 W/System.err﹕ at org.jivesoftware.smackx.iqregister.AccountManager.createAccount(AccountManager.java:272)
10-01 02:58:54.444    1747-3673/com.example.eoin_a.im_app20 W/System.err﹕ at com.example.eoin_a.im_app20.Utils.ConnectionManager.registerDevice(ConnectionManager.java:109)
10-01 02:58:54.444    1747-3673/com.example.eoin_a.im_app20 W/System.err﹕ at com.example.eoin_a.im_app20.Models.RegisterModel$1.call(RegisterModel.java:110)
10-01 02:58:54.444    1747-3673/com.example.eoin_a.im_app20 W/System.err﹕ at com.example.eoin_a.im_app20.Models.RegisterModel$1.call(RegisterModel.java:93)
10-01 02:58:54.445    1747-3673/com.example.eoin_a.im_app20 W/System.err﹕ at java.util.concurrent.FutureTask.run(FutureTask.java:237)

Iam also getting a "User tried to authenticate with this server using an unknown recipient" message in the log on my openfire server. I am not too sure what this means.

I am sending all the extra params in a map that are required by the server also.

below is the code i use to create my connection

 config = XMPPTCPConnectionConfiguration.builder()
                .setHost(HOST)
                .setPort(PORT)
              .setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
                .setServiceName(HOST)
                .setUsernameAndPassword(ACCOUNT, PASS)
                .build();
             conn = new XMPPTCPConnection(config);
             conn.setPacketReplyTimeout(10000);
             accman = AccountManager.getInstance(conn);

Iam using the default xmpp.domain on the sever which just seems to be the private ip address in server settings. I am not sure if this will cause the issue. If anyone has any info on why this may not be working for me I would appreciate some help. Thanks!

I just experienced the same error. In my case I called accountManager.createAccount() after connection.login() . The hint on how to solve the problem was in Javadoc of accountManager.supportsAccountCreation() .

Returns true if the server supports creating new accounts. Many servers require that you not be currently authenticated when creating new accounts, so the safest behavior is to only create new accounts before having logged in to a server.

So make sure, you are not logged in, when creating new accounts! At least it solved my problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM