Sending message to AIM transport when user is offline == connection loss

Hey,

I’‘ve found that transports are pretty unreliable - but oh well. One problem arises that is more than a trivial concern: Sometimes transports don’‘t send you presence packets for your buddies - for instance an AIM buddy. This means that you just kinda have to guess if he’'s online or not, or request presence notification from him.

That’‘s fine, but if you send him a message and he’'s offline, your transport will send you back a message like this:

<message from="aim.netmindz.net/registered" type="error" to="aolsen@valhalla.dydns.com/laptop" >
<error>faimtest: message to _____ bounced (reason 0x0004: Not logged on)
</error>
</message>

I don’'t know why, but this causes the smack library to disconnect - or at least a packet to be sent to the connection listener.

Can someone point in the right direction to fixing it?

Message was edited by: synic

Adam,

I just uploaded a new Aug 20 daily build. Can you try your test with that build? The important change is that ConnectionListener interface reports errors better (so also make sure you’'ve registered a connection listener to print out errors). If you get a stack trace that seems strange, let me know.

Regards,

Matt

Matt,

With the new library I now get a ClassCastException when trying to connect - here is the line (316 in XMPPConnection.java) that causes it:

Authentication authResponse = (Authentication)response;

Thanks

Adam,

Could you turn on Smack debugging and then paste in the packet that is causing Smack to blow up? It should be authentication response packet. Also, pasting in the full stack trace would help too.

Thanks,

Matt

Matt,

Here’'s the stack trace:

Java version 1.4.2 ok
Exception in thread "main" java.lang.ClassCastException
        at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:316)
        at com.valhalla.jbother.gui.ConnectorThread.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
        at com.valhalla.jbother.gui.AutoLoginDialog.login(Unknown Source)
        at com.valhalla.jbother.JBotherLoader.startJBother(Unknown Source)
        at JBother.main(Unknown Source)

And here’'s the packet information I got back from the server:

<?xml version=''1.0''?><stream:stream xmlns:stream=''http://etherx.jabber.org/streams'' id=''3F43DBF2'' xmlns=''jabber:client'' from=''valhalla.dydns.com''>
<iq id=''396Jy-0'' type=''result''><query xmlns=''jabber:iq:auth''><username>aolsen</username><password/><digest/>
<sequence>499</sequence><token>3F2575DE</token><resource/></query></iq>
<iq id=''396Jy-1'' type=''result''/>

Matt,

Sorry, here’'s a stack trace with debugging turned on (oops).

Exception in thread "main" java.lang.ClassCastException
        at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:316)
        at com.valhalla.jbother.gui.ConnectorThread.run(ConnectorThread.java:52)         at java.lang.Thread.run(Unknown Source)
        at com.valhalla.jbother.gui.AutoLoginDialog.login(AutoLoginDialog.java:7
2)
        at com.valhalla.jbother.JBotherLoader.startJBother(JBotherLoader.java:91
)
        at JBother.main(JBother.java:69)

Adam,

Thanks for the additional details. I posted a new Aug 20 build that should fix the issue.

Regards,

Matt

Matt,

Thanks for the quick responses! No more ClassCastException, and no more connection loss when I send to an offline AIM buddy.

Adam

hrmm,

Unfortunately, it happens intermittently, but more often than not (even after using the latest version). I don’'t get any errors, just disconnected when I try to send to an offline aim transport contact.

What can I do to get more information? I don’'t get a stack trace or anything.

Thanks,

Adam

Adam,

Have you used the ConnectionListener interface to log whether the connection is closing due to errors? That should be the first thing you check. Also, perhaps it’‘s the server that’'s closing the connection? You should see if you can duplicate the issue on a non-Smack client.

-Matt

Matt,

It doesnt’’ close Psi, and yes, it’'s closing on error, not just closing ?

What’'s the error? Can you paste in the stack trace?

-Matt

Sorry it took so long to reply. I was away from my computer over the weekend.

Here’'s the stack trace I get:

java.lang.NumberFormatException: null

at java.lang.Integer.parseInt(Integer.java:436)

at java.lang.Integer.parseInt(Integer.java:518)

at org.jivesoftware.smack.PacketReader.parseError(PacketReader.java:596)

at org.jivesoftware.smack.PacketReader.parseMessage(PacketReader.java:641)

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

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

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

It looks like the server isn’‘t sending an error code with the error packet. I’‘m not sure that’‘s valid… anyone know if it’'s supposed to be?

-Matt

In XMPP 1.0 the error subelement is a MUST

http://www.jabber.org/ietf/draft-ietf-xmpp-core-17.html#stanzas-error

In Jabber (XMPP 0.9) it was never rigidly defined. However, I would say it SHOULD and probably MUST. However, since it wasn’'t specified, I think we need to be able to handle the case where the error subelement is not included.

-iain