隨筆-95  評(píng)論-31  文章-10  trackbacks-0
          問(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ì)象工廠(chǎng)
               
          */
              
          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 朔望魔刃 閱讀(382) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): 即時(shí)通信

          只有注冊(cè)用戶(hù)登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 潢川县| 盘锦市| 弋阳县| 犍为县| 桐乡市| 山东省| 烟台市| 玉门市| 安岳县| 仲巴县| 周至县| 洛扎县| 平乐县| 垦利县| 桦甸市| 屏边| 昆明市| 洛浦县| 祁阳县| 彰化县| 中江县| 城市| 炎陵县| 洛浦县| 沾化县| 青神县| 石景山区| 高青县| 江陵县| 重庆市| 白山市| 宁武县| 恭城| 芷江| 晴隆县| 平潭县| 宜兴市| 徐水县| 九龙城区| 宁明县| 鄱阳县|