【问题标题】:Asmack 18 connection : google.com:5222 Exception: Could not connect to talk.google.com remote-server-timeoutAsmack 18 连接:google.com:5222 异常:无法连接到 talk.google.com 远程服务器超时
【发布时间】:2013-11-29 15:08:02
【问题描述】:

我正在尝试使用 asmack 18 连接到 gtlak 服务器以进行 XMPP 连接。

public static final String HOST = "talk.google.com";
public static final int PORT = 5222;
public static final String SERVICE = "gmail.com";

ConnectionConfiguration connConfig = new ConnectionConfiguration(HOST, PORT, SERVICE);
    XMPPConnection connection = new XMPPConnection(connConfig);

    try {
      //Connect to the server
      connection.connect();
      connection.login("xxxxxxxx@gmail.com", "password");
    // Set the status to available
      Presence presence = new Presence(Presence.Type.available);
      connection.sendPacket(presence);
      //xmppClient.setConnection(connection);
      Log.d("connection","connection successfull");
    } catch (XMPPException ex) {
      connection = null;
      Log.d("connection","connection fail");
      //Unable to connect to server
    }

但它给出了超时错误。 talk.google.com:5222 例外:无法连接到talk.google.com:5222。; :远程服务器超时(504) -- 引起:java.net.UnknownHostException:talk.google.com

【问题讨论】:

    标签: android xmpp asmack google-talk


    【解决方案1】:

    阅读自述文件 =) http://asmack.freakempire.de/0.8.9/README

    静态代码

    为了在 Android 上正常工作,您需要注册 Smack 的 XMPP Providers and Extensions 手动初始化一些静态代码 在您执行任何 XMPP 活动之前阻止。打电话 SmackAndroid.init(Context)(在 org.jivesoftware.smack 中)会这样做 给你。

        SmackAndroid.init(getApplicationContext());
        ConnectionConfiguration connConfig = new ConnectionConfiguration("talk.google.com", 5222, "gmail.com");
    ...
    

    .

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-20
      • 1970-01-01
      • 2019-10-18
      • 1970-01-01
      • 2015-03-19
      • 1970-01-01
      相关资源
      最近更新 更多