moved heartbeat connection opening into try block.