【发布时间】:2016-09-16 23:47:34
【问题描述】:
我正在尝试使用 smack 在 localhost 上连接到 openfire/ejabberd(我已经对它们进行了配置并测试了与 strophe.js 的连接)。这是我尝试过的:
Log.d(TAG, "Connecting to server " + mServiceName);
XMPPTCPConnectionConfiguration.Builder config = XMPPTCPConnectionConfiguration.builder();
config.setUsernameAndPassword("test_user1@home", "password");
config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
config.setServiceName("home");
config.setHost("127.0.0.1");
config.setPort(5222);
config.setCompressionEnabled(true);
config.setDebuggerEnabled(true);
final XMPPTCPConnection xmpptcpConnection = new XMPPTCPConnection(config.build());
SASLAuthentication.blacklistSASLMechanism("DIGEST-MD5");
mConnection = new XMPPTCPConnection(config.build());
mConnection.setPacketReplyTimeout(10000);
mConnection.addConnectionListener(this);
mConnection.connect();
mConnection.login();
但我回来了:
org.jivesoftware.smack.SmackException$ConnectionException: The following addresses failed: '127.0.0.1:5222' failed because java.net.ConnectException: failed to connect to /127.0.0.1 (port 5222) after 30000ms: isConnected failed: ECONNREFUSED (Connection refused)
我正在使用手机进行连接。我认为这种情况正在发生,因为它没有在互联网上注册。我已经购买了一个域并创建了一个子域,但我不知道如何使用它注册我的 openfire/ejabberd 服务器。
如果构建器配置有任何应有的地方,谁能给我一些关于如何注册它的说明?
编辑:要在公共帐户上注册 openfire,我必须启用 ssh 并进行一些配置(我宁愿不这样做)。没有办法在我的本地帐户上测试我的安卓应用吗?
【问题讨论】:
-
如果您有本地网络,请将您的手机和计算机连接到它。并将 IPv4 作为主机。
-
我想我试过了。通过无线电话、计算机电缆和来自 ipconfig 的 IP。不幸的是,我遇到了同样的错误。
-
你可以查看我的post here
标签: android ejabberd openfire smack