隨筆-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 朔望魔刃 閱讀(382) 評論(0)  編輯  收藏 所屬分類: 即時通信
          主站蜘蛛池模板: 郯城县| 肥东县| 蓝田县| 郴州市| 胶南市| 河间市| 柳江县| 皮山县| 沁源县| 崇州市| 灵川县| 茌平县| 高青县| 拜泉县| 莲花县| 阿尔山市| 开封市| 晋江市| 汉阴县| 黄平县| 新乡县| 安溪县| 航空| 澄城县| 南靖县| 灵武市| 宜兴市| 旬阳县| 舟山市| 修文县| 普陀区| 龙海市| 西安市| 镇远县| 汾阳市| 阿鲁科尔沁旗| 舟曲县| 贵德县| 沧源| 阆中市| 新兴县|