2015-08-08 30 views
2

我正在嘗試使用smack客戶端4.1.2創建用戶。我正在低於錯誤。XMPPError:使用smack創建新用戶時禁止驗證錯誤4.1.2

Send XML on stream = <<"<iq from='abc.example.com' to='[email protected]/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 

我仍然得到上述錯誤。請幫助

添加代碼片段展示如何創建使用嫌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; 
} 
+0

看起來你配置文件的縮進是錯誤的。 –

回答

4

我發現了這個問題。這是由於trusted_network標記具有作爲回送的值:允許在ejabberd配置文件中。我將它改爲all:allow。它開始工作。

0

配置的片斷,你提供過小,嚴重縮進新用戶,所以它是不可能告訴你什麼是你的配置錯誤。

但是,考慮到您的配置是正確的,您應該在發送註冊請求之前檢查您的用戶是否使用正確的ACL憑證進行了正確驗證。大多數客戶端庫採取自我用戶註冊並嘗試在進行任何形式的身份驗證之前發送註冊表。

+0

嗨雷蒙德,對遲到的迴應表示歉意。我使用yamlLint檢查了yml文件,併成功解析了它。所以沒有格式問題。如何在發送註冊請求之前檢查用戶是否使用正確的ACL憑證進行身份驗證。 –

+0

嗨Remond,我添加了一個代碼片段,我嘗試創建用戶。請讓我知道,如果這給你任何暗示問題 –

+0

這可能是一個問題?它在我的配置yml文件中。 '##只允許從本地主機 trusted_network註冊: 迴環:允許 ## ##在服務器計算機只有客戶可以註冊賬戶 ## ip_access:如果是這樣trusted_network」,我應該改變的價值? –

相關問題