Smack Exception : stream:error (text)

Initially when using smack over the weekend, everything was fine, my code was working like I expected… but recently later in the day yesterday and today I keep getting repeated messages of the type:

stream:error (text)

at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:306)

at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:44)

at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:76)

stream:error (text)

at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:306)

at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:44)

at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:76)

Any ideas, what is causing this and how I can prevent this?

Check to see if the same user is trying to log into a multi-user chat more than once using the same resource name.

If userX is logging into the MUC mychat@conference.server/resource1 more than once, you will get that message.

Right on! Thanks. My script was logging a user to the MUC a second time in another thread.

Can this be thrown for different reasons?

I’m trying a simple testcase:

ConnectionConfiguration configuration = new ConnectionConfiguration(“talk.google.com”, 5222);
configuration.setSASLAuthenticationEnabled(true);
XMPPConnection conn1 = new XMPPConnection(configuration);
conn1.connect();
conn1.login(“blip”, “pazzword”);
ChatManager chatManager = conn1.getChatManager();

Chat chat = chatManager.createChat(“blob”,new MessageListener(){
@Override
public void processMessage(Chat arg0, Message arg1) {
System.out.println(arg1);
}} );
chat.sendMessage(new Message(“w00t”));

There is no reason for me to believe that any other connection is being made.

From the test I get the exception at the login statement in the snippet above:

No response from the server.:
at org.jivesoftware.smack.NonSASLAuthentication.authenticate(NonSASLAuthentication .java:74)
at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java: 351)
at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:395)
at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:349)

From another thread I get the very useful:

stream:error (text)
at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:306)
at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:44)
at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:76)

I could use some tips on debugging this, because the connection terminates while I have the debugger open and then the parser gives a different error.

Just to help with the diagnosis, you have the main thread where you try to create the chat room. Then at the end of your message you are saying that

From another thread I get the very useful:

stream:error (text)

What credentials does that thread use to log in. If they are the same credentials, you may have the reason for the exception. And yes, the exception message could be more informative.

If the error message would say something like: please check you are using the right resource and credentials, that would have helped me.

To be more precise, you have to use:

ConnectionConfiguration configuration = new ConnectionConfiguration(“talk.google.com”, 5222, gmail.com);

and:

Chat chat = chatManager.createChat(“blob**@gmail.com**”, //and some other arguments obviously

I have no idea where that is documented, but it seems to be the only way that it works. So the reason that it didn’t work is not a bug in Smack, but merely a lack of information on how to connect to google talk. I’ve seen quite a few other posts on this forum on that, and even blogs that show the wrong way to do it, so it might be nice to have some more information in the error. However, if the server just doesn’t give you that information there isn’t much you can do about it I guess.