Server dropping messages with stream management enabled

Ganesh Krishnan
Added almost 4 years ago

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. has



Replies (2)


Added by Artur Hefczyc TigaseTeam almost 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.

Added by Ganesh Krishnan almost 4 years ago

Thanks for the heads up Artur. I have added a stanza acknowledgement listener to the client and resend the message if I don't get a ACK in 5 seconds