2

我在 android 中有以下代码,使用 asmack api for gtalk app

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

            try {
                connection.connect();
                SASLAuthentication.supportSASLMechanism("PLAIN", 0);
            } catch (XMPPException ex) {
                Log.e("XMPPChatDemoActivity", "Failed to connect to "
                        + connection.getHost());
                Log.e("XMPPChatDemoActivity", ex.toString());
                setConnection(null);
            }
            try 
                connection.login(USERNAME, PASSWORD);
                Log.i("XMPPChatDemoActivity",
                        "Logged in as " + connection.getUser());

                
            } catch (XMPPException ex) {
                Log.e("XMPPChatDemoActivity", "Failed to log in as "
                        + USERNAME);
                Log.e("XMPPChatDemoActivity", ex.toString());
                setConnection(null);
            }

在 AVD 上运行应用程序时出现此错误

无法连接到talk.google.com

XMPPError 连接到 talk.google.com:5222.: remote-server-error(502) XMPPError 连接到 talk.google.com:5222。

-- 由:java.net.ConnectException:无法连接到我的服务器(端口 5222)的 talk.google.com/ip 地址:连接失败:ETIMEDOUT(连接超时)

4

0 回答 0