Asmack 18连接:google.com:5222异常:无法连接到远程talk.google.com服务器超时 [英] Asmack 18 connection : google.com:5222 Exception: Could not connect to talk.google.com remote-server-timeout
问题描述
我想asmack使用18连接到gtlak服务器XMPP连接。
公共静态最后弦乐HOST =talk.google.com;
公共静态最终诠释PORT = 5222;
公共静态最后弦乐SERVICE =gmail.com;ConnectionConfiguration connConfig =新ConnectionConfiguration(主机,端口,服务);
XMPPConnection连接=新XMPPConnection(connConfig); 尝试{
//连接到服务器
connection.connect();
connection.login(xxxxxxxx@gmail.com,密码);
//将状态设置为可用
presence presence =新的presence(presence.Type.available);
connection.sendPacket(presence);
//xmppClient.setConnection(connection);
Log.d(连接,连接全成);
}赶上(XMPPException前){
连接= NULL;
Log.d(连接,连接失败);
//无法连接到服务器
}
但它给超时错误。
talk.google.com:5222例外:无法连接到talk.google.com:5222; :远程服务器超时(504)
- 致:的java.net.UnknownHostException:talk.google.com
阅读自述=) HTTP ://asmack.freakempire.de/0.8.9/README
静态code
为了在Android上正常工作,您需要注册啪的
XMPP提供商和手动扩展和初始化一些静态code
你以前块做任何XMPP activty。调用
SmackAndroid.init(上下文)(适用于org.jivesoftware.smack)将做到这一点
给你的。
块引用>SmackAndroid.init(getApplicationContext());
ConnectionConfiguration connConfig =新ConnectionConfiguration(talk.google.com,5222,gmail.com);
...
I am trying to use asmack 18 to connect to gtlak server for XMPP connection.
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 }
But it gives timeout error. talk.google.com:5222 Exception: Could not connect to talk.google.com:5222.; : remote-server-timeout(504) -- caused by: java.net.UnknownHostException: talk.google.com
解决方案Read the ReadME =) 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"); ...
.
这篇关于Asmack 18连接:google.com:5222异常:无法连接到远程talk.google.com服务器超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!