What is the right way to keep user's connection

Igor Khomenko
Added about 4 years ago

What is the right way to keep user's connection?

Is it enough to send TCP keep alive packets periodically?

Or should user send presence packets periodically, for example each 1 min?

Replies (1)


Added by Artur Hefczyc TigaseTeam about 4 years ago

Usually you have very little control on whether the user's connection stays open. There is "idle" timer in Tigase which closes connections after 24h of inactivity and to avoid closing connection by Tigase, then any kind of XMPP activity with 24h window is enough.

However, the connection is often closed outside of the XMPP server or client. Mobile network providers periodically cleanup all TCP/IP connections, regardless they are idle or busy, there are sometimes, network problems and/or errors which cause connection closure and many others. This often results in a connection broken in such a way that neither the client or the server knows about the problem, so both sides may still attempt to send data on the connection, and the data is lost.

So what you really need to do, is, you have to monitor whether the connection is still opened and working correctly. One of possible option is to send periodically XMPP ping and/or add support for stream resumption XEP in your client.