繁体   English   中英

连接到XMPP服务器

[英]connect to xmpp server

我尝试通过此代码连接到我的xmpp服务器

    final String servicename = "my server ip";  
    XMPPTCPConnection connection;


    public void Register(String userName, String password)throws XMPPException, SmackException, IOException
    {
   try{
          XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
          .setServiceName(servicename)
          .setUsernameAndPassword("admin username", "admin password")
          .setCompressionEnabled(false).build();

          connection = new XMPPTCPConnection(config);

          connection.connect();
          AccountManager AM = AccountManager.getInstance(connection);
          AM.createAccount(userName, password);
          connection.disconnect();
          System.out.println(":)");
     } 
     catch(XMPPException e){
          System.out.println(":(");            
     }

    }

所有的代码都在try catch中,但是当我调用此函数时,没有任何输出并得到错误。

我是Java的新手,但我认为它从配置声明中出错

我从这里复制配置声明

我怎样才能解决这个问题?

提前致谢

我终于找到answer.it似乎嫌4后,你需要一些更多的jar文件添加到您的项目和解决我的问题,其中之一就是这个

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM