android客户端无法连接到openfire服务器

turboc12 2014-07-01 05:39:27
我的代码如下

private int SERVER_PORT = 5222;
private String SERVER_HOST = "127.0.0.1";
private XMPPConnection connection = null;
private String SERVER_NAME = "erpguy2jeonknua";
/**
* 打开连接
*/
public boolean openConnection() {
try {
if (null == connection || !connection.isAuthenticated()) {
XMPPConnection.DEBUG_ENABLED = true;// 开启DEBUG模式
// 配置连接
ConnectionConfiguration config = new ConnectionConfiguration(
SERVER_HOST, SERVER_PORT, SERVER_NAME);
config.setReconnectionAllowed(true);
config.setSASLAuthenticationEnabled(false); // 是否启用安全验证
config.setDebuggerEnabled(true);
config.setSecurityMode(ConnectionConfiguration.SecurityMode.required);
connection = new XMPPConnection(config);
StrictMode.ThreadPolicy policy = new
StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
connection.connect();// 连接到服务器
// 配置各种Provider,如果不配置,则会无法解析数据
configureConnection(ProviderManager.getInstance());
return true;
}
} catch (XMPPException xe) {
xe.printStackTrace();
connection = null;
}
return false;
}

每次运行走到connection.connect();之后就跳到catch (XMPPException xe) ,无法连接,请问是为什么?哪的问题呢?
...全文
138 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
hjy逸影 2015-01-11
  • 打赏
  • 举报
回复
我也是这个问题,请问解决了吗

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧