2016-10-19 1 views
3

을 사용하여 새 사용자 생성 오류 클라이언트 라이브러리 4.1.8 및 xmpp 서버 (openfire 서버)를 사용하여 채팅 응용 프로그램을 개발했지만 새 사용자를 만들려고 시도하는 중 사용 Accountmanger 클래스가 제기 예외 : -XMPPError : 잘못된 요청 - smack 라이브러리 4.1.8 및 openfire

XMPPTCPConnectionConfiguration conf = XMPPTCPConnectionConfiguration.builder() 
         .setSecurityMode(ConnectionConfiguration.SecurityMode.disabled) 
         .setHost("127.0.0.1") 
         .setDebuggerEnabled(true) 
         .setPort(5222) 
         .setSendPresence(true) 
         .setServiceName("127.0.0.1") 
         .build(); 

       AbstractXMPPConnection conn2 = new XMPPTCPConnection(conf); 

       //conn2.login(); 
       conn2.connect(); 

       AccountManager accountManager = AccountManager.getInstance(conn2); 
       if (accountManager.supportsAccountCreation()) { 
        accountManager.sensitiveOperationOverInsecureConnection(true); 
        accountManager.createAccount("qidus", "123456"); 
        conn2.login("qidus", "123456"); 

       } 

      } catch (SmackException | IOException | XMPPException e) { 
       e.printStackTrace(); 
      } 

을 "XMPPError 나쁜 요청 수정"을 제외하고는이

04:01:41 AM SENT (0): <iq to='127.0.0.1' id='aYej1-3' type='get'><query xmlns='jabber:iq:register'></query></iq> 

오전 4시 1분 41초의 RECV (0)입니다 :

,

답변

3

서비스 이름을 올바르게 설정해야합니다. adminfirm (127.0.0.1:9090)을 통해 OpenFire에서 serviceName을 확인하실 수 있습니다. 페이지 중앙의 첫 번째 페이지에 로그인 한 후 "서버 이름"을 찾으십시오.

기본적으로 컴퓨터 이름입니다.

그러나 코드는 한 번만 실행됩니다. 두 번째로 AccountManger는 이미 등록 된 사용자로 인해 예외를 throw합니다.

+0

감사합니다. 정말 문제를 해결했습니다. – Qidus

+0

당신은 환영합니다, 대답을 수락 해 주시기 바랍니다 :) – MrPk

0

계정 생성을 위해 전달하는 사용자 이름에 null 값이있는 경우에도이 오류 또는 예외가 발생합니다. 사용자 이름도 확인하십시오.

관련 문제