gpt4 book ai didi

android - 无法将 aSmack 客户端与我在 Android 中的 ejabberd2 服务器连接

转载 作者:行者123 更新时间:2023-11-29 16:07:24 25 4
gpt4 key购买 nike

我使用 XMPP 创建一个聊天应用程序:

为此,我在我的 Android 应用程序中使用 eJabberd2 作为服务器,使用 asmack 库 (asmack-2010.05.07.jar) 作为客户端,

我可以连接到主机 talk.google.com 但无法连接到我的 eJabberd 主机。

我的代码是:

1) 工作正常:

    @Override
protected Void doInBackground(Void... arg0) {
ConnectionConfiguration cc = new ConnectionConfiguration( "talk.google.com", 5222, "gmail.com" );
XMPPConnection connection = new XMPPConnection(cc);
try {
SASLAuthentication.supportSASLMechanism("PLAIN");
cc.setSASLAuthenticationEnabled(true);
connection.connect();
Roster.setDefaultSubscriptionMode(Roster.SubscriptionMode.manual);
Log.i("XMPPClient", "[SettingsDialog] Connected to "
+ connection.getHost());

} catch (XMPPException e1) {
Log.e("XMPPClient", e1.toString());
}
}

2) 不工作: 我的 eJabberd 在 http://68.178.255.136:5280/admin/

@Override
protected Void doInBackground(Void... arg0) {
ConnectionConfiguration cc = new ConnectionConfiguration( "68.178.255.136", 5280, "68.178.255.136" );
XMPPConnection connection = new XMPPConnection(cc);
try {
SASLAuthentication.supportSASLMechanism("PLAIN");
cc.setSASLAuthenticationEnabled(true);
connection.connect();
Roster.setDefaultSubscriptionMode(Roster.SubscriptionMode.manual);
Log.i("XMPPClient", "[SettingsDialog] Connected to "
+ connection.getHost());

} catch (XMPPException e1) {
Log.e("XMPPClient", e1.toString());
}
}

O/P :

06-06 17:20:27.231: E/XMPPClient(446): Connection failed. No response from server.: 
06-06 17:20:27.381: W/System.err(446): java.net.SocketException: Socket closed
06-06 17:20:27.381: W/System.err(446): at org.apache.harmony.luni.platform.OSNetworkSystem.read(Native Method)
06-06 17:20:27.381: W/System.err(446): at dalvik.system.BlockGuard$WrappedNetworkSystem.read(BlockGuard.java:273)
06-06 17:20:27.381: W/System.err(446): at org.apache.harmony.luni.net.PlainSocketImpl.read(PlainSocketImpl.java:458)
06-06 17:20:27.381: W/System.err(446): at org.apache.harmony.luni.net.SocketInputStream.read(SocketInputStream.java:85)
06-06 17:20:27.381: W/System.err(446): at java.io.InputStreamReader.read(InputStreamReader.java:255)
06-06 17:20:27.381: W/System.err(446): at java.io.BufferedReader.read(BufferedReader.java:311)
06-06 17:20:27.381: W/System.err(446): at org.kxml2.io.KXmlParser.peek(KXmlParser.java:925)
06-06 17:20:27.381: W/System.err(446): at org.kxml2.io.KXmlParser.peekType(KXmlParser.java:589)
06-06 17:20:27.381: W/System.err(446): at org.kxml2.io.KXmlParser.nextImpl(KXmlParser.java:333)
06-06 17:20:27.381: W/System.err(446): at org.kxml2.io.KXmlParser.next(KXmlParser.java:1378)
06-06 17:20:27.381: W/System.err(446): at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:326)
06-06 17:20:27.381: W/System.err(446): at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:44)
06-06 17:20:27.381: W/System.err(446): at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:71)

最佳答案

我认为问题出在您提供的端口上,请使用 5222 而不是 5280,因为在 XMPP 中,客户端连接的是 5222 而不是 5280。

关于android - 无法将 aSmack 客户端与我在 Android 中的 ejabberd2 服务器连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16962207/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com