【发布时间】:2014-08-28 08:07:37
【问题描述】:
我正在尝试使用 SMACK API 连接到 gmail,但出现以下错误,并且过去 2 天我被困住了。
Exception in thread "main" org.jivesoftware.smack.sasl.SASLErrorException: SASLError using PLAIN: not-authorized
at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:348)
at org.jivesoftware.smack.tcp.XMPPTCPConnection.login(XMPPTCPConnection.java:244)
at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:442)
我正在使用 smack 4.0.3 jar 和 Java 7。我的办公网络中没有阻止 gmail。我已经厌倦了论坛中给出的所有建议。
1. setting SASLMechanism to PLAIN / DIGEST-MD5.
2. adding the Thread.sleep delay after connect.
3. by setting the dummy SSLSocketFactory.
4. removing the domain name from user name.
以下是我正在尝试执行的代码。
public class JabberExample {
public static void main(String[] args) throws Exception{
XMPPTCPConnection con = new XMPPTCPConnection("gmail.com");
SASLAuthentication.supportSASLMechanism("PLAIN",0);
con.connect();
con.login("username", "password");
Chat chat = ChatManager.getInstanceFor(con).createChat("chatusernam@gmail.com", new MessageListener() {
public void processMessage(Chat chat, Message message) {
System.out.println("Received message: " + message);
}
});
chat.sendMessage("Message..!!");
con.disconnect();
}
}
希望我能在这里得到一些建议和帮助。
【问题讨论】:
标签: xmpp smack google-talk