隨筆-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 朔望魔刃 閱讀(389) 評論(0)  編輯  收藏 所屬分類: 即時通信
          主站蜘蛛池模板: 德惠市| 河东区| 甘德县| 东方市| 桓台县| 滦平县| 达州市| 承德县| 洪雅县| 屏边| 绥棱县| 桐梓县| 大关县| 黄浦区| 沁阳市| 吴川市| 麻栗坡县| 嘉义县| 灵丘县| 拜城县| 曲麻莱县| 芦山县| 潢川县| 邳州市| 共和县| 东乡族自治县| 定安县| 贵溪市| 榆中县| 马鞍山市| 锦州市| 宁乡县| 高淳县| 遂溪县| 清原| 密云县| 龙口市| 弥渡县| 维西| 濉溪县| 哈尔滨市|