one of the our distributed apps are using heart beat to detect the peer's disconnection(e.g. LAN line broken, etc) . is the heart beating necessary?
Yes. TCP would only show that the physical connection is still alive (ie. the socket was not teared down by routers or by OS). But will tell nothing about the application availability. If the process at the other end of your pipe is in a while(1);
loop and is not processing your requests, you aren't really connected to it.
That is quite a good way to know that you are still connected to the other end at the "application level" and applications can still talk. Otherwise you would have to make assumptions that "the other end" has nothing to "say", which would be hard to separate from "the other end actually lost network connectivity 35 seconds ago".
Maybe, what will do you if you don't get the heart beat?
If you have no way to recover there is no point in having a heart beat.
If you are using call-back from the server to the client, you need a way that the client can ask the server to resent all lost call-backs, this is not easy.
Also if you don’t get a heart beat it does not mean a message will not get there later, as there can be all sort of network delays, is it safe to just resent your messages?
The heart beat is the easy bit, the hard bit is what to do when the heart does not beat!