Server dropping messages with stream management enabled
I am using Smack beta-3 on android for sending messages. After some idle time the messages are not sent to the server. I can't see it in the logs or anything.
Smack debug log file shows the message as being sent
_02-10 22:27:27.705 31506-742/co.intouch D/SMACK﹕ SENT (0): then3b8323e2-91b9-4cb7-adf1-25515c2aea8f
02-10 22:27:27.706 31506-742/co.intouch D/SMACK﹕ SENT (0): _
However the usual ACK () on client side is sometimes missing especially if the app has been idel. The dev of Smack, Flow, confirmed that Smack is indeed writing to the socket because these debug log is being output.
So I am curious where this message goes and why isn't the server logging anything?
I have stream management enabled on tigase.
Added by Artur Hefczyc about 4 years ago
It is quite common and normal that the connection is broken but neither the server or the client know about it. To the server or to the client the socket looks like OK, even though the connection is not working. So, the client can put data into a network socket but they never get delivered and are lost. For that reason, the client (or the server) should never consider a packet sent (or delivered for that matter) unless it receives ACK for this packet.
To avoid such situations and quickly detect broken connections it is recommended to send a ping from a client to the server at regular interval of time (once a minute is usually good enough). Then if there is not response to the ping within a specified time, the client can consider the connection broken and should reopen a new connection.