gpt4 book ai didi

android - Asmack 18 连接 : google. com :5222 Exception: Could not connect to talk. google.com 远程服务器超时

转载 作者:行者123 更新时间:2023-11-29 21:25:20 24 4
gpt4 key购买 nike

我正在尝试使用 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

最佳答案

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

Static Code

In order to work correctly on Android, you need to register Smack's XMPP Providers and Extensions manually and init some static code blocks before you doing any XMPP activty. Calling SmackAndroid.init(Context) (in org.jivesoftware.smack) will do this for you.

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

.

关于android - Asmack 18 连接 : google. com :5222 Exception: Could not connect to talk. google.com 远程服务器超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20288633/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com