创建新用户时Smack XMPP错误:禁止 - 身份验证

时间:2015-05-13 09:28:55

标签: java xmpp smack mongoose-im

我正在尝试通过管理员帐户创建新用户。但是我收到了auth错误。 我试过像this这样的答案,但它没有帮助。

我创建新用户的代码:

AccountManager accountManager = AccountManager.getInstance(mConnection);

        if (accountManager.supportsAccountCreation()) {
            try {
                accountManager.createAccount(username, password);
            }

            catch (XMPPException ex) {
                LOG.info(ex.getMessage(), ex);
            }

        }
        else{
            LOG.error("Server doesn't support creating new accounts");
        }

我允许在配置中注册ALL:

{access, register, [{allow, all}]}.

{access, register_from, [{allow, all}]}.

{mod_register, [
 ...
 {ip_access, [{allow, "127.0.0.0/8"},
              {deny, "0.0.0.0/0"}]},
 {access_from, register_from},
 {access, register}
]},

即使使用此配置我也有错误:

org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPPError: forbidden - auth
    at org.jivesoftware.smack.XMPPException$XMPPErrorException.ifHasErrorThenThrow(XMPPException.java:135)
    at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:232)
    at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:213)
    at org.jivesoftware.smackx.iqregister.AccountManager.createAccount(AccountManager.java:272)
    at org.jivesoftware.smackx.iqregister.AccountManager.createAccount(AccountManager.java:244)

P.S。 Smack 4.1.0

1 个答案:

答案 0 :(得分:1)

解决方案:

step1:

enter image description here

step2:

enter image description here

step3:

enter image description here

完成所有这三个步骤后,运行您的程序,您将能够在ejabberd服务器上注册新用户。