SASL authorization failing while connecting to XMPP server

SPB picture SPB · Sep 17, 2010 · Viewed 10.2k times · Source

I am trying to connect to gmail using SMACK API through XMPP server. but getting the

error : SASL authentication failed using mechanism PLAIN

you can check a glimpse of code. I got it from net only

ConnectionConfiguration connConfig = new ConnectionConfiguration("talk.google.com", 5222, "gmail.com");
connection = new XMPPConnection(connConfig);
connection.connect();
SASLAuthentication.supportSASLMechanism("PLAIN", 0);

I checked in the smack debug window. it says in XML :

< invalid-authzid />

I am already having account on gmail and my gtalk is also running.

Answer

Chuk Lee picture Chuk Lee · Sep 20, 2010

You need to set the authentication before you connect viz

SASLAuthentication.supportSASLMechanism("PLAIN", 0);

must appear before connection.connect().

See my blog.