Bugs I've run into in 3.1.0: ConnectionListener, Presence problems, Carriage return escaping

So I’ve run into a few annoying problems using Smack. This is really a great library in lots of ways, but it definitely has a few quirks. I don’t expect these issues to be addressed - I just want to get it out there so if anyone feels like fixing them, they can. :slight_smile:

ConnectionListener:

  • reconnection callbacks are called while the connection state is incomplete. There are some threads on this, for example if you want to rejoin a chatroom after a reconnect. The workaround is to launch a new thread and sleep for a few seconds before doing anything.

Presence:

  • Presence support for IM gateways on openfire is flaky at best. I realize the roster is non-persistent, but the problem in smack is it’s not even consistent. If a user is offline for a long time, smack “forgets” the user, but still considers that user on its roster. So when the user comes back online, smack still thinks he’s offline even if you do a reload() on the roster. Not sure the workaround for this yet (forcefully remove/readd the user?).

Carriage return escaping:

  • This is minor but annoying nonetheless. Smack seems to escape incoming \r into \n on linux systems. So that means if someone in windows aim does shift-enter, it inserts \r\n, and then when you get the message in smack it’s turned into \n\n. So it doubles all newlines, and there’s no way to disable this behavior. It would be correct just to convert \r\n into \n. I have to manually squish all \n\n into \n which is ugly.

Random disconnects:

  • Haven’t traced this down, but smack occasionally does something that causes openfire to disconnect it. Smack’s error message is nonexistent if it gets disconnected by the server, so this is hard to figure out without access to openfire’s logging. Also happens sporadically, so hard to figure it out.