我已经尝试了足够但在尝试通过openfire服务器上的smack 4.1注册用户时没有任何登录(匿名)时收到错误。通过用户登录,注册工作正常。
我已经检查了Smack 4.1 Android anonymous registration to Openfire链接,但仍然收到相同的错误(错误请求 - 修改)。
<iq type="error" id="R6rBt-3" from="192.168.0.105" to="desktop-ebr9dof/a96febd1"><query xmlns="jabber:iq:register"><username>user4</username><password>uhifg123</password></query><error code="400" type="modify"><bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>
下面的是我在代码中应用的代码段:
XMPPTCPConnectionConfiguration.Builder configBuilder = XMPPTCPConnectionConfiguration.builder();
configBuilder.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
configBuilder.setServiceName("192.168.0.105");
configBuilder.setHost("192.168.0.105");
configBuilder.setPort(5222);
configBuilder.setDebuggerEnabled(true);
configBuilder.setCompressionEnabled(false);
configBuilder.setSendPresence(true);
configBuilder.setUsernameAndPassword("user4", "uhifg123");
XMPPTCPConnection connection = new XMPPTCPConnection(configBuilder.build());
try {
connection.connect();
AccountManager accountManager = AccountManager.getInstance(connection);
accountManager.sensitiveOperationOverInsecureConnection(true);
Map<String, String> map = new HashMap<String, String>();
map.put("username", "user4");
map.put("password", "uhifg123");
SASLAuthentication.unBlacklistSASLMechanism("PLAIN");
SASLAuthentication.blacklistSASLMechanism("DIGEST-MD5");
try {
accountManager.createAccount("user4", "uhifg123", map);
} catch (SmackException.NoResponseException e) {
e.printStackTrace();
} catch (XMPPException.XMPPErrorException e) {
e.printStackTrace();
} catch (SmackException.NotConnectedException e) {
e.printStackTrace();
}
} catch (SmackException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (XMPPException e) {
e.printStackTrace();
}