XMPPTCPConnection.isAuthenticated() and XMPPTCPConnection.isConnected() both return true even the connection is lost

Hi,All

I met an strange issue on some kind of android phone with the smack 4.1.1.

My code is below, i use the contidition: **isConnected() and isAuthenticated() to check if the connection is reliable or not, but i found in some kind of android phone there is an stranger issue that is the isConnected() and ** isAuthenticated() will both return true, but in the openfile management part, this user is offline in fact

if(connection.isConnected()&&connection.isAuthenticated()){

this connection is valid and no need to reconnect it

}else{
reconnect and login it}

My question is: can **isConnected() and ** isAuthenticated() ****be the right condition to judge if the connection is valid or not?If no, what is the right condition code that i should have to write.Thanks a lot!!!

-llsha

My question is: can isConnected() and isAuthenticated() be the right condition to judge if the connection is valid or not?

No it is not, because of the inherent asynchronous nature of TCP connections and their design.

If no, what is the right condition code that i should have to write
PingManager.pingMyServer() allows you to detect if the connection is still alive. But note that false does not necessary mean that it’s broken.

Hi,Flow

Thanks for you kind help, i found that the PingManager.pingMyServer() can found out the broken connection, that’s great!

One more thing, If the connection was broken that the PingManager.pingMyServer() will always return false,right?