問(wèn)題:
出現(xiàn) DIGEST-MD5, Not authcated 等等
解決:
smack版本:4.2.2
pom.xml依賴(lài)<dependency>
<groupId>org.igniterealtime.smack</groupId>
<artifactId>smack-core</artifactId>
<version>${smack.version}</version>
</dependency>
<dependency>
<groupId>org.igniterealtime.smack</groupId>
<artifactId>smack-im</artifactId>
<version>${smack.version}</version>
</dependency>
<dependency>
<groupId>org.igniterealtime.smack</groupId>
<artifactId>smack-extensions</artifactId>
<version>${smack.version}</version>
</dependency>
<dependency>
<groupId>org.igniterealtime.smack</groupId>
<artifactId>smack-tcp</artifactId>
<version>${smack.version}</version>
</dependency>
<dependency>
<groupId>org.igniterealtime.smack</groupId>
<artifactId>smack-experimental</artifactId>
<version>${smack.version}</version>
</dependency>
<dependency>
<groupId>org.igniterealtime.smack</groupId>
<artifactId>smack-sasl-provided</artifactId>
<version>${smack.version}</version>
</dependency>
<dependency>
<groupId>org.igniterealtime.smack</groupId>
<artifactId>smack-java7</artifactId>
<version>${smack.version}</version>
</dependency>
Smack的配置代碼: /**
* 初始化對(duì)象工廠
*/
public XMPPConnectionObjectPool() {
//XMPP連接配置
XMPPTCPConnectionConfiguration.Builder builder = XMPPTCPConnectionConfiguration.builder();
try {
configuration = builder.
setXmppDomain(domain).
setHost(ip).
setPort(port).
setCompressionEnabled(true).
setSecurityMode(ConnectionConfiguration.SecurityMode.disabled).build();
} catch (XmppStringprepException e) {
LOGGER.error("init XMPPTCPConnectionConfiguration failed! {}", e);
throw new ServiceException("init XMPPTCPConnectionConfiguration failed!", ErrorCode.INIT_XMPP_CONFIG_FAILED);
}
}
Smack連接openfire的代碼:
try {
xmpptcpConnection.connect();
xmpptcpConnection.login(atomicIntegerLoginName.getAndIncrement() + "", loginPassword, Resourcepart.from("web"));
} catch (SmackException | IOException | XMPPException | InterruptedException e) {
LOGGER.error("Login openfire failed! the reason is : {}", e.getMessage());
throw new LoginServiceException(e);
}
以上方式如果還出現(xiàn)DIGEST-MD5, Not authcated 等等1:查看用戶(hù)名和密碼是否正確
2:查看openfire的ofProperty表,找到這一行:
查看where后面的條件是否是user_name, 也就是用什么字段來(lái)驗(yàn)證用戶(hù)名和密碼的。即可解決
完!
posted on 2017-12-22 17:58
朔望魔刃 閱讀(378)
評(píng)論(0) 編輯 收藏 所屬分類(lèi):
即時(shí)通信