gpt4 book ai didi

android - Smack 4.1 SASL 认证错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:42:59 25 4
gpt4 key购买 nike

我正在使用适用于 Android 的 Smack 4.1 native 库来开发聊天应用程序。我能够在我的应用程序和我的服务器之间设置连接,但我在登录时收到有关 SASL 身份验证的 SmackException。

注意事项

  1. 我的服务器端不需要 SASL 身份验证。
  2. 我的应用程序没有崩溃,但出现了以下错误,我在我的日志 cat fragment 中显示了这些错误。

我使用的是 eclipse Luna 和 JDK 1.7 版,我在 libs 文件夹中包含了以下库。

  1. jxmpp-core-0.4.1
  2. jxmpp-util-cache-0.4.1
  3. minidns-0.1.1
  4. smack-android-4.1.0.jar
  5. smack-android-extensions-4.1.0
  6. smack-core-4.1.0
  7. smack-extensions-4.1.0
  8. smack-im-4.1.0
  9. smack-tcp-4.1.0

这是我用来建立连接的代码。

XMPPTCPConnectionConfiguration.Builder configBuilder = XMPPTCPConnectionConfiguration.builder();
configBuilder.setUsernameAndPassword(userName, pass);
configBuilder.setSecurityMode(XMPPTCPConnectionConfiguration.SecurityMode.disabled);
configBuilder.setResource("testServices");
configBuilder.setServiceName(DOMAIN);
configBuilder.setPort(PORT);
configBuilder.setHost(DOMAIN);
configBuilder.setDebuggerEnabled(true);

AbstractXMPPConnection connection = new XMPPTCPConnection(
configBuilder.build());

/** Connecting to the server */
try {
connection.connect();
Log.i(TAG, "Connected to " + connection.getHost());
} catch (SmackException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (XMPPException e) {
Log.e(TAG, "Failed to connect to " + connection.getHost());
Log.e(TAG, e.toString());
e.printStackTrace();
}

/** LogingIn to the server */
try {

//SASLMechanism.PLAIN();
//SASLAuthentication.("PLAIN", 0);

connection.login(userName, pass);
// connection.login();
} catch (XMPPException e) {
e.printStackTrace();
} catch (SmackException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

/** LogingOut from the server */
connection.disconnect();

这是我的 logcat 输出。

04-20 22:22:51.584: D/SMACK(8335): SENT (0): <stream:stream xmlns='jabber:client' to='my_server_url' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' from='10001@my_server_url' xml:lang='en'>
04-20 22:22:52.519: D/SMACK(8335): RECV (0): <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" version="1.0" id="0768491716592086" from="my_server_url">
04-20 22:22:53.744: D/SMACK(8335): RECV (0): <stream:features><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>PLAIN</mechanism></mechanisms></stream:features>
04-20 22:22:53.749: I/(8335): Connected to "smy_server_url"

04-21 12:24:55.815: I/(16566): SmackException to my_server_link.comorg.jivesoftware.smack.SmackException: SASL Authentication failed. No known authentication mechanisims.
04-20 22:22:53.754: W/System.err(8335): org.jivesoftware.smack.SmackException: SASL Authentication failed. No known authentication mechanisims.
04-20 22:22:53.759: W/System.err(8335): at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:254)
04-20 22:22:53.759: W/System.err(8335): at org.jivesoftware.smack.tcp.XMPPTCPConnection.loginNonAnonymously(XMPPTCPConnection.java:365)
04-20 22:22:53.759: W/System.err(8335): at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java:452)
04-20 22:22:53.759: W/System.err(8335): at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java:427)
04-20 22:22:53.759: W/System.err(8335): at com.epixoft.ui.LoginActivity$ConnectionTestTask.doInBackground(LoginActivity.java:120)
04-20 22:22:53.759: W/System.err(8335): at com.epixoft.ui.LoginActivity$ConnectionTestTask.doInBackground(LoginActivity.java:1)
04-20 22:22:53.759: W/System.err(8335): at android.os.AsyncTask$2.call(AsyncTask.java:288)
04-20 22:22:53.759: W/System.err(8335): at java.util.concurrent.FutureTask.run(FutureTask.java:237)
04-20 22:22:53.759: W/System.err(8335): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
04-20 22:22:53.764: W/System.err(8335): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
04-20 22:22:53.764: W/System.err(8335): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
04-20 22:22:53.764: W/System.err(8335): at java.lang.Thread.run(Thread.java:841)
04-20 22:22:53.784: D/SMACK(8335): SENT (0): <presence id='PwoLk-3' type='unavailable'><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.igniterealtime.org/projects/smack' ver='NfJ3flI83zSdUDzCEICtbypursw='/></presence>
04-20 22:22:53.789: D/SMACK(8335): SENT (0): </stream:stream>
04-20 22:22:53.864: E/ViewRootImpl(8335): sendUserActionEvent() mView == null

在此先感谢您的帮助。干杯:)

最佳答案

经过一番努力,我终于找到了解决问题的方法。

我必须导入 smack-sasl-provided-4.1.0.jar 以消除此 SASL 身份验证错误。

关于android - Smack 4.1 SASL 认证错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29755230/

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