Java和Jabber / Smack [英] Java and Jabber/Smack

查看:141
本文介绍了Java和Jabber / Smack的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用最新版本的Smack(3.2.1)编写一个简单的示例来在两个帐户之间发送和接收消息。

I am trying to code a simple example using the latest version of Smack (3.2.1) to send and receive messages between two accounts.

Connection connection = new XMPPConnection("jabber.org");
connection.connect();
connection.login("username", "password");

但我甚至无法通过登录部分。当我运行上面的代码时,我得到了这个异常:

But I can't even get past the login part. When I run the above code I get this exception:

Exception in thread "main" SASL authentication DIGEST-MD5 failed: invalid-authzid: 
at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:337)
at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:203)
at org.jivesoftware.smack.Connection.login(Connection.java:348)
at com.smack.TestSmack.main(TestSmack.java:19)

这里发生了什么?我确信我的用户名和密码有效,因为我可以使用我的IM客户端登录。

What is going on here? I am sure my username and password work because I can log in using my IM client.

还有人能指出我目前正在研究Smack的例子吗?这非常令人沮丧,因为文档和库似乎不同步。

And can anyone point me to current working Smack examples? This is very frustrating because the documentation and the library seem out of sync.

谢谢 -

推荐答案

您能否检查一下您是否在用户名末尾添加@ jabber.org?如果你这样做,它将无法工作。

Could you check that you are not adding "@jabber.org" at the end of the username? if you do, it will not work.

否则,如果你已经这样做了,你可能想尝试使用

Otherwise, if you do that already, you may want to try using

SASLAuthentication.supportSASLMechanism(PLAIN,0);

connection.login(username,password);

这篇关于Java和Jabber / Smack的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆