随笔-95  评论-31  文章-10  trackbacks-0
问题: 
      出现 DIGEST-MD5, Not authcated 等等

解决:
smack版本:4.2.2
pom.xml依赖


<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的配置代码:
    /**
     * 初始化对象工厂
     
*/
    
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);
        }


以上方式如果还出现DIGEST-MD5, Not authcated 等等

1:查看用户名和密码是否正确
2:查看openfire的ofProperty表,找到这一行:
查看where后面的条件是否是user_name, 也就是用什么字段来验证用户名和密码的。即可解决

完!
posted on 2017-12-22 17:58 朔望魔刃 阅读(355) 评论(0)  编辑  收藏 所属分类: 即时通信

只有注册用户登录后才能发表评论。


网站导航: