Why does the Android client need to send a heartbeat?




One, kindergarten


The so-called keep-alive means to ensure that the link is alive:

For example, in China Mobile 2G,
various provinces had different timeout control strategies for TCP,
30 minutes long and 5 minutes short;
therefore, if no data is sent for about 5 minutes, it may be interrupted by domestic operators;

Therefore, after a TCP link is established, it is
generally appropriate to send a heartbeat packet every four and a half minutes to keep it alive.




2. Detection


The server cannot be connected to a certain user after it is connected,
because the connection needs to consume server resources;

Through the heartbeat, the server can detect which clients are dead.
For dead clients, the server can disconnect and release resources.

The reverse is also true. The
client also uses the heartbeat to determine whether the server is down.
If it is down, change the address to re-establish a long connection.




Guess you like

Origin blog.csdn.net/weixin_44648216/article/details/113850637