Correctly know when client lost connection

Hi, I’m using smack in android for the client and openfire as the server and I have a problem when the client losses the internet connectivity but still thinks is connected to the server because it sends the message and gets lost.

I’ve tried using AbstractXMPPConnection.isConnected() but it believes is still connected.