Add sending of heartbeats to keep the connection alive and quickly detect dead sockets. Trigger reconnection logic when socket was broken.