Add default heartbeat and fix stop heartbeat

* Add the default heartbeat of 25 seconds

* Stop hearbeat when the connection is closed

* Fix float value division