1 问题描述
conflict(409)
at org.jivesoftware.smack.AccountManager.createAccount(AccountManager.java:240)
at org.jivesoftware.smack.AccountManager.createAccount(AccountManager.java:203)
2 smack创建用户代码
public boolean register(String username, String password) {
logger.debug("username:{}, password:{}", username, password);
try {
ConnectionConfiguration config = new ConnectionConfiguration(openfireUrl, Integer.parseInt(openfirePort));
/** 是否启用压缩 */
config.setCompressionEnabled(true);
/** 是否启用安全验证 */
config.setSASLAuthenticationEnabled(true);
connection = new XMPPConnection(config);
connection.connect();
connection.getAccountManager().createAccount(username,password);
return true;
} catch (Exception e) {
e.printStackTrace();
logger.info("连接openfire服务器失败,ip: {} port:{} ",openfireUrl, openfirePort);
return false;
}
}
3 解决方案
原因是因为微信端连接的openfire服务器域,后台的openfire服务器端不是同一台导致。