> - sleek detects connection loss after a fairly long time (more than a minute?)
This would be the result of using a socket in blocking mode -- it waits until the OS says the connection is dead, but TCP tends to try to keep connections alive as long as possible. I'd prefer to use non-blocking sockets because of this, but it will take some work.
> - It then attempts to reconnect every second.
There should be a backoff so that it doesn't do that every second. Which version are you using?
> - If the connection is regained after some attempts, these messages are not transmitted/received, suggesting that there is no buffering happening inside the library.
Right, if the socket accepts the data, then its removed from the send queue because it is up to the OS at that point. If not, the send queue is still flushed on disconnect since Iq stanzas mess things up (ie, sending results from previous session in the new one).
> I would like to detect these connection losses, and take appropriate steps to persist the data.
Your best bet is to use the XEP-0198 plugin which is meant to solve this exact issue (with session resumption). Hopefully you are able to use a server which supports it. If not, you can still look at the source for it to see how the buffering there works.
If your server doesn't support XEP-0198, but the other clients you're sending messages to support XEP-0184 for message receipts, those can be used to manage a buffer of sent messages.
If neither of those apply, then using XEP-0199 for pings with a small timeout should give you faster notification that the connection has gone stale.
-- Lance