fix the reconnect logic and send heart