Error code 405 on XMPPConnection.login GoogleTalk

Im trying to connect to google talk with smack. I can estabilish connection to talk.google.com, but only seldomly I can login. Usually when XMPPConnection.login is called I get Clast Cast Exception in SASLAuthentication.authenticate.

This is code that causes CCE:

if (hasTypeClient) {

log.error(">>>>>>>>>>>>>>>>>>>>>>>>>args: connectionID:“connectionID” serverHost:“serverHost” serverPort:“serverPort” username:“username” password:“password” resource:“resource”<<<<<<<<<<<<<<<<<<<<<<<");

log.error(">>>>>>>>>>>>>>>>>>>>>>>>>hasTypeClient CALL<<<<<<<<<<<<<<<<<<<<<<<");

/c = new XMPPConnection(serverHost, serverPort, serviceName);/c=new GoogleTalkConnection();

c.DEBUG_ENABLED=true;

log.error(">>>>>>>>>>>>>>>>>>>>>>>>>hasTypeClient CALL GOT CONN<<<<<<<<<<<<<<<<<<<<<<<");

c = addPacketListeners(c,packetFilters);

log.error(">>>>>>>>>>>>>>>>>>>>>>>>>hasTypeClient CALL ADDED PACKER FILTERS<<<<<<<<<<<<<<<<<<<<<<<");

c.login(username,password,resource);

log.error(">>>>>>>>>>>>>>>>>>>>>>>>>hasTypeClient CALL Logged in<<<<<<<<<<<<<<<<<<<<<<<");

}

And here is console output I get:

20:45:14,937 ERROR >>>>>>>>>>>>>>>>>>>>>>>>>args: connectionID:org.mobicents.examples.wakeupbot.WakeUpBotSbb serverHost:talk.google.com serverPort:5222 username:ezgar.pl password:passs13 resource:MobicentsWakeUpBot<<<<<<<<<<<<<<<<<<<<<<<

20:45:14,937 ERROR >>>>>>>>>>>>>>>>>>>>>>>>>hasTypeClient CALL<<<<<<<<<<<<<<<<<<<<<<<

20:45:15,640 INFO 08:45:15 PM SENT (23701597):

20:45:15,656 INFO 08:45:15 PM SENT (23701597): <stream:stream to=“gmail.com” xmlns=“jabber:client” xmlns:stream=“http://etherx.jabber.org/streams” version=“1.0”>

20:45:15,937 INFO 08:45:15 PM RCV (23701597): <?xml version="1.0" encoding="UTF-8"?><stream:stream from=“gmail.com” id=“631EFE6130412111” version=“1.0” xmlns:stream=“http://etherx.jabber.org/streams” xmlns=“jabber:client”>

20:45:15,937 INFO 08:45:15 PM RCV (23701597):

20:45:15,937 INFO 08:45:15 PM SENT (23701597):

20:45:16,093 INFO 08:45:16 PM RCV (23701597):

20:45:17,218 INFO 08:45:17 PM SENT (23701597): <stream:stream to=“gmail.com” xmlns=“jabber:client” xmlns:stream=“http://etherx.jabber.org/streams” version=“1.0”>

20:45:17,375 INFO 08:45:17 PM RCV (23701597): <?xml version="1.0" encoding="UTF-8"?><stream:stream from=“gmail.com” id=“4A600D5F42913B00” version=“1.0” xmlns:stream=“http://etherx.jabber.org/streams” xmlns=“jabber:client”>

20:45:17,390 ERROR >>>>>>>>>>>>>>>>>>>>>>>>>hasTypeClient CALL GOT CONN<<<<<<<<<<<<<<<<<<<<<<<

20:45:17,390 ERROR >>>>>>>>>>>>>>>>>>>>>>>>>hasTypeClient CALL ADDED PACKER FILTERS<<<<<<<<<<<<<<<<<<<<<<<

20:45:17,390 INFO 08:45:17 PM RCV (23701597):

20:45:27,406 INFO 08:45:27 PM SENT (23701597):

20:45:27,765 INFO 08:45:27 PM RCV (23701597):

20:45:27,781 INFO 08:45:27 PM SENT (23701597): <stream:stream to=“gmail.com” xmlns=“jabber:client” xmlns:stream=“http://etherx.jabber.org/streams” version=“1.0”>

20:45:27,921 INFO 08:45:27 PM RCV (23701597): <?xml version="1.0" encoding="UTF-8"?><stream:stream from=“gmail.com” id=“73C552FF56D16287” version=“1.0” xmlns:stream=“http://etherx.jabber.org/streams” xmlns=“jabber:client”>

20:45:27,937 INFO 08:45:27 PM RCV (23701597):

20:45:27,937 INFO 08:45:27 PM SENT (23701597):

20:45:28,093 INFO 08:45:28 PM RCV (23701597):

20:45:28,171 INFO java.lang.ClassCastException: org.jivesoftware.smack.PacketReader$4

20:45:28,171 INFO at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java: 175)

20:45:28,171 INFO at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:352)

20:45:28,171 INFO at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:318)

20:45:28,171 INFO at org.mobicents.slee.resource.xmpp.XmppResourceAdaptor$XMPPConnectionListener.run (XmppResourceAdaptor.java:557)

20:45:28,187 INFO 08:45:28 PM SENT (23701597):

20:45:28,343 INFO 08:45:28 PM RCV (23701597):

20:45:28,359 INFO (405)

20:45:28,359 INFO at org.jivesoftware.smack.NonSASLAuthentication.authenticate(NonSASLAuthentication .java:62)

20:45:28,359 INFO at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java: 215)

20:45:28,359 INFO at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:352)

20:45:28,359 INFO 08:45:28 PM RCV (23701597): </stream:stream>

20:45:28,375 INFO 08:45:28 PM SENT (23701597):

20:45:28,375 INFO 08:45:28 PM SENT (23701597): </stream:stream>

20:45:28,375 INFO at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:318)

20:45:28,375 INFO at org.mobicents.slee.resource.xmpp.XmppResourceAdaptor$XMPPConnectionListener.run (XmppResourceAdaptor.java:557)

“Already authenticated.” - this is strange, I dont have any other connections estabilished, this one is first.

What could be the problem?