aSmack 4.0.* XMPPTCPConnection 无法连接到 OpenFire 和 Ejabbered (SmackException$NoResponseException)
aSmack 4.0.* XMPPTCPConnection can't connect to OpenFire and Ejabbered (SmackException$NoResponseException)
我正在使用 asmack-android-8-source-4.0.6
当我尝试连接到服务器时,无论是 openFire 还是 Ejabbered,我都遇到了这个异常
org.jivesoftware.smack.SmackException$NoResponseException
这是我的代码:
SmackAndroid.init(getApplicationContext());
ConnectionConfiguration conConfig = new ConnectionConfiguration(HOST, PORT);
conConfig.setDebuggerEnabled(true);
connection = new XMPPTCPConnection(conConfig);
try {
connection.connect();
Log.i("AppName", "CONNECTED TO " + connection.getHost());
}
当我打电话给
connection.connect();
我得到这个异常:
org.jivesoftware.smack.SmackException$NoResponseException
请注意,我已经在 asmack-android-19-0.8.10 上尝试了相同的代码,它运行良好
我想问题出在
XMPPTCPConnection
因为在 asmack-android-19-0.8.10 我使用
XMPPConnection
有什么帮助吗?
我发现了问题,我所做的就是添加这一行:
ConnectionConfiguration.setSecurityMode(SecurityMode.disabled);
并且我已成功连接到服务器
最后是我的配置:
ConnectionConfiguration ConnectionConfiguration = new ConnectionConfiguration(HOST, PORT);
ConnectionConfiguration.setDebuggerEnabled(true);
ConnectionConfiguration.setSecurityMode(SecurityMode.disabled);
试试这个:
public void connect()
{
Thread t = new Thread(new Runnable() {
@Override
public void run() {
SmackAndroid.init(getApplicationContext());
ConnectionConfiguration conConfig = new ConnectionConfiguration(HOST, PORT);
conConfig.setDebuggerEnabled(true);
conConfig.setSecurityMode(SecurityMode.disabled);
connection = new XMPPTCPConnection(conConfig);
try {
connection.connect();
connection.login("unm", "pswd");
Presence presence = new Presence(Presence.Type.available);
connection.sendPacket(presence);
setConnection(connection);
} catch (XMPPException e) {
e.printStackTrace();
} catch (SmackException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
});
t.start();
}
我正在使用 asmack-android-8-source-4.0.6
当我尝试连接到服务器时,无论是 openFire 还是 Ejabbered,我都遇到了这个异常
org.jivesoftware.smack.SmackException$NoResponseException
这是我的代码:
SmackAndroid.init(getApplicationContext());
ConnectionConfiguration conConfig = new ConnectionConfiguration(HOST, PORT);
conConfig.setDebuggerEnabled(true);
connection = new XMPPTCPConnection(conConfig);
try {
connection.connect();
Log.i("AppName", "CONNECTED TO " + connection.getHost());
}
当我打电话给
connection.connect();
我得到这个异常:
org.jivesoftware.smack.SmackException$NoResponseException
请注意,我已经在 asmack-android-19-0.8.10 上尝试了相同的代码,它运行良好
我想问题出在
XMPPTCPConnection
因为在 asmack-android-19-0.8.10 我使用
XMPPConnection
有什么帮助吗?
我发现了问题,我所做的就是添加这一行:
ConnectionConfiguration.setSecurityMode(SecurityMode.disabled);
并且我已成功连接到服务器
最后是我的配置:
ConnectionConfiguration ConnectionConfiguration = new ConnectionConfiguration(HOST, PORT);
ConnectionConfiguration.setDebuggerEnabled(true);
ConnectionConfiguration.setSecurityMode(SecurityMode.disabled);
试试这个:
public void connect()
{
Thread t = new Thread(new Runnable() {
@Override
public void run() {
SmackAndroid.init(getApplicationContext());
ConnectionConfiguration conConfig = new ConnectionConfiguration(HOST, PORT);
conConfig.setDebuggerEnabled(true);
conConfig.setSecurityMode(SecurityMode.disabled);
connection = new XMPPTCPConnection(conConfig);
try {
connection.connect();
connection.login("unm", "pswd");
Presence presence = new Presence(Presence.Type.available);
connection.sendPacket(presence);
setConnection(connection);
} catch (XMPPException e) {
e.printStackTrace();
} catch (SmackException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
});
t.start();
}