powered by Jive Software

How to detect that a client disconnected due to network failure


I am developing an IM mobile application and I’m still new at Openfire which I am using as my server. The problem I am facing is the following: the Openfire server does not detect automatically when a client disconnects due to a network failure (for example if he looses his wifi connection…) and hence waits for a certain timeout before considering the client to be offline. This is bad since any message sent to this client during the timeout will be lost since the server will not store as it considers this client ot be still online. Hence I need to know if there is any method to detect from the server that the connection with the client has been lost due to network failure.

Any ideas?


You can’t. This is related to how TCP works. The momment the device loses the connection it has no chance to tell it’s server that it is gone. The only way to see if the device has received its message is send back a “received” notification and store the message in case you don’t.

I don’t know how this complies with the XMPP Protocol, maybe there is already such a feature.

Thx @Chrisliebaer,

It seems you’re right and there are no ways of detecting that the client went offline due to a connection failure. That’s why I am thinking of storing all the messages received by the server and then delete the ones that were successfully routed to their destination.

Thx again

There is an XMPP extension XEP-0184 (Message Delivery Receipts). But it is not for the server side. It’s a protocol for xmpp clients. Smack library already supports that (SMACK-331). Maybe you can use it as an example for your application.