Correct jid&pwd can''t login first time, but logined second time

Hello, everyone:

I am writing one jabber client with smack2.1, sometimes( most happened in the machine first install my jabber client and log in first time) when log in the jabber server with correct jid and password, an exception throwed out as below, but I can log in the server with same jid and password in the second time.

The exception is :

SASL authentication failed:

at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java: 205)

at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:410)

at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:374)

at iTechEasy.iJabber.login(iJabber.java:108)

at iTechEasy.iControl.login(iControl.java:207)

at iTechEasy.iLoginUI.login(iLoginUI.java:184)

at iTechEasy.iLoginUI.keyPressed(iLoginUI.java:428)

at java.awt.Component.processKeyEvent(Unknown Source)

at javax.swing.JComponent.processKeyEvent(Unknown Source)

at java.awt.Component.processEvent(Unknown Source)

at java.awt.Container.processEvent(Unknown Source)

at java.awt.Component.dispatchEventImpl(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)

at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)

at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)

at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)

at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)

at java.awt.Component.dispatchEventImpl(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Window.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

Is anybody know the reason? Please tell me. Many thanks!

Hi,

I have problems using Smack and non-SSL connections. I did not setup a testcase as

a) these problems are odd and

b) using SSL connections (XMPPConnection con = new SSLXMPPConnection(host, port)) solved my problem.

Are you using SSL?

LG

Thanks.

I have changed my connect to SSLXMPPConnection, But same error happened again. Some times correct jid and password can’'t log in first time.

(401)

at org.jivesoftware.smack.NonSASLAuthentication.authenticate(NonSASLAuthentication .java:94)

at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:414)

at iTechEasy.iJabber.login(iJabber.java:112)

at iTechEasy.iControl.startLogin(iControl.java:234)

at iTechEasy.iLoginUI.login(iLoginUI.java:223)

at iTechEasy.iLoginUI.keyPressed(iLoginUI.java:521)

at java.awt.Component.processKeyEvent(Unknown Source)

at javax.swing.JComponent.processKeyEvent(Unknown Source)

at java.awt.Component.processEvent(Unknown Source)

at java.awt.Container.processEvent(Unknown Source)

at java.awt.Component.dispatchEventImpl(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)

at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)

at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)

at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)

at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)

at java.awt.Component.dispatchEventImpl(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Window.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

Hi,

here is a very short sample code which fails. Do we have a problem with missing libraries or something similar? The stacktrace is independant of the Server Security Settings.

If I use the old SSL method and port 5223 login works fine for me.

Maybe someone can confirm that the code below works fine?

LG

public class Login

{

public static void main(String[] args) throws Exception

{

String Servername= “jabber.host.tld”;

int Serverport = 5222;

String Username = “test”;

String Password = “test”;

XMPPConnection con;

XMPPConnection.DEBUG_ENABLED=true;

con = new XMPPConnection(Servername);

con.login(Username, Password); // causes stacktrace

con.close();

con = null;

};

};

Raw Sent Packets:

java.lang.ClassCastException: org.jivesoftware.smack.PacketReader$4

at org.jivesoftware.smack.SASLAuthentication.bindResourceAndEstablishSession(SASLA uthentication.java:300)

at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java: 210)

at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:410)

at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:374)

at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:355)

at Login.main(Login.java:38)

Exception in thread “main” (401)

at org.jivesoftware.smack.NonSASLAuthentication.authenticate(NonSASLAuthentication .java:94)

at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java: 224)

at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:410)

at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:374)

at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:355)

at Login.main(Login.java:38)

/code

It is just my fault as the correct jid and pwd is not correct.