XMPPError:forbidden auth error while creating new user using smack 4.1.2

XMPPError:forbidden auth error while creating new user using smack 4.1.2

我正在尝试使用 smack 客户端 4.1.2 创建用户。我遇到错误。

Send XML on stream = <<"<iq from='abc.example.com' to='admin@abc.example.com/Smack' id='Dym8b-14' type='error'><query xmlns=jabber:iq:register><password>xxxxxx</password><username>user</username><registered/></query><error code=403 type=auth><forbidden xmlns=urn:ietf:params:xml:ns:xmpp-stanzas/></error></iq>">>

我的 ejabberd 配置如下所示(.yml 文件)

register_from:
admin: allow
...
access_from: register_from
access: register

我仍然遇到上述错误。请帮忙

添加代码片段以展示我如何使用 smack 4.1.0 创建新用户

connection = new XMPPTCPConnection(getConnectionConfiguration());
                connection.connect();
                connection.login("admin", "admin");
                if(connection.isAuthenticated())
                {
                    AccountManager accountManager = AccountManager.getInstance(connection);
                    accountManager.sensitiveOperationOverInsecureConnection(true);
                    accountManager.createAccount(userName, password);
                    connection.disconnect();
                    // The account has been created, so we can now login
                    connection.login(userName, password);
                }

private XMPPTCPConnectionConfiguration getConnectionConfiguration()
{

    XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
              .setServiceName("abc.example.com")
               .setHost("abc.example.com")
               .setPort(5222)
              .build(); 

    return config;
}

您提供的配置片段太小且缩进严重,因此无法告诉您配置中的错误。

但是,考虑到您的配置是正确的,您应该在发送注册请求之前检查您的用户是否使用正确的 ACL 凭据进行了正确的身份验证。大多数客户端库假设用户自行注册,并在进行任何形式的身份验证之前尝试发送注册。

我发现了问题。这是由于 trusted_network 标签在 ejabberd 配置文件中的值为 loopback:allow。我把它改成了all:allow。它开始工作了。