diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ab18b901e9c0992cee072ed41c43d06c67c0b729..bfc6597c990ec6cf475528c4256a45e8ff31aacd 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -66,11 +66,13 @@ testDebian:
     script:
         - apt-get update && apt-get install -y git jq faketime expect cron
         - git clone https://github.com/sstephenson/bats.git
+        - ./agent-1234.run --quiet
         - cd bats
         - ./install.sh /usr
         - cd ../test
         - ./create_users.sh
         - last -F
+        - cat /opt/agentC3SL/conf/datasid-conf.json
         - ./returnTest.bats
     dependencies:
         - compileUnix
@@ -82,9 +84,11 @@ testUbuntu:
         - regular
     script:
         - apt-get update && apt-get install -y bats jq faketime expect cron
+        - ./agent-1234.run --quiet
         - cd test
         - ./create_users.sh
         - last -F
+        - cat /opt/agentC3SL/conf/datasid-conf.json
         - ./returnTest.bats
     dependencies:
         - compileUnix
@@ -99,9 +103,11 @@ testOpensuse:
         - touch /var/log/wtmp
         - chown root.tty /var/log/wtmp
         - chmod 664 /var/log/wtmp
+        - ./agent-1234.run --quiet
         - cd test
         - ./create_users.sh
         - last -F
+        - cat /opt/agentC3SL/conf/datasid-conf.json
         - ./returnTest.bats
     dependencies:
         - compileUnix
diff --git a/README.md b/README.md
index 930b2c0307069a1f9bcadacb82d5b8d08835f588..6cc974b6310862911b8e72c4627c31f41b2bceb1 100644
--- a/README.md
+++ b/README.md
@@ -11,6 +11,7 @@ Using *Linux* as default
 - c++ compiler
 - cmake
 - libudev
+- make-self
 
 
 <a name="HeaderBuildingAndCompiling"></a>
diff --git a/conf/datasid-conf.json b/conf/datasid-conf.json
index 9f2e72fb8219069289033e1e9be45e0305ec2b9c..38348398eaee1e184cc45c1bb56bf429928757d2 100644
--- a/conf/datasid-conf.json
+++ b/conf/datasid-conf.json
@@ -1,7 +1,7 @@
 {
-    "idPoint" : "%d",
-    "proxyConf" : "%s",
-    "webService": "%s",
-    "version": "%s",
-    "project" : "%s"
+	"idPoint" : "%d",
+	"project" : "%s",
+	"proxyConf" : "%s",
+	"version" : "%s",
+	"webService" : "%s"
 }
\ No newline at end of file
diff --git a/conf/proxy-conf.json b/conf/proxy-conf.json
index 0109f41afa03b42c278acf0717006e29468114fe..ef745cdc1cf9cfa9cc4ead6419236dbc1f19bedb 100644
--- a/conf/proxy-conf.json
+++ b/conf/proxy-conf.json
@@ -3,4 +3,4 @@
 "port" : "%d",
 "usr" : "%s",
 "password" : "%s"
-}
+}
\ No newline at end of file
diff --git a/generate_agent.sh b/generate_agent.sh
index 6bfe5ace29554aaaa30ca2e1b0fb46acffd96412..a276553b6b99679c8afda7dc460371167b84f1c6 100755
--- a/generate_agent.sh
+++ b/generate_agent.sh
@@ -101,7 +101,7 @@ tmp=$(cat ../../../conf/proxy-conf.json)
 printf "$tmp\n" $host $port $usr $passwd  > proxy.json
 
 tmp=$(cat ../../../conf/datasid-conf.json)
-printf "$tmp\n" $idPoint /opt/agentC3SL/conf/proxy-conf.json $webService $version $project > datasid-conf.json
+printf "$tmp\n" $idPoint $project /opt/agentC3SL/conf/proxy-conf.json $version $webService   > datasid-conf.json
 
 
 cd ../../..
diff --git a/include/agent/agent.h b/include/agent/agent.h
index 290d82904f5bca346e21136d57d2107bd5615ce9..e370ba638608476d3c5becadc5f8b148a6709e79 100644
--- a/include/agent/agent.h
+++ b/include/agent/agent.h
@@ -1,6 +1,7 @@
 #pragma once
 #include <iostream>
 #include <fstream>
+#include <agent/connection.h>
 #include <agent/parse_config_file.h>
 #include <agent/parse_proxy_file.h>
 #include <boost/filesystem.hpp>
@@ -24,6 +25,7 @@
  * <br><br>
 */
 
+class Connection; // forward declarations
 class Conf; // forward declarations
 class Proxy; // forward declarations
 
@@ -34,20 +36,23 @@ class Agent{
         std::string pathDirInstall; /*!< Absolute path from local to install agent */
         std::string pathLogDir; /*!< Absolute path from log directory */
         std::string pathLogFile; /*!< Absolute path from log file */
-        std::string message; /*!< Success, warning and error messages to be setted in logfile */
         std::string prefix; /*!< Absolute path from agent */
         std::string installerName; /*!< Name of agent installer file */
+        Connection* connection;
         Conf* conf;
         Proxy* proxy;
 
     public:
+        // We can't return fstream type
+        std::fstream logFile;
+
         void setPathConfDir(std::string);
         void setPathConfigFile(std::string);
         void setPathLogDir(std::string);
         void setPathLogFile(std::string);
-        void setMessage(std::string);
         void setPrefix(std::string, int);
         void setInstallerName(std::string);
+        void setConnection(Connection*);
         void setConf(Conf*);
         void setProxy(Proxy*);
 
@@ -55,9 +60,9 @@ class Agent{
         std::string getPathConfigFile() const;
         std::string getPathLogDir() const;
         std::string getPathLogFile() const;
-        std::string getMessage() const;
         std::string getPrefix() const;
         std::string getInstallerName() const;
+        Connection* getConnection() const;
         Conf* getConf() const;
         Proxy* getProxy() const;
 
diff --git a/include/agent/common.h b/include/agent/common.h
index 0a35622a959df86374a9323f7fbf0ae43b72151c..255505b335d1d12765485a5d80801bf9968d2bbc 100644
--- a/include/agent/common.h
+++ b/include/agent/common.h
@@ -7,6 +7,8 @@
 #include <boost/filesystem.hpp>
 #include <json/json.h>
 
+class Agent; // forward declarations
+
 /** @file common.h
  * @brief This file has a purpose to make parse from config and proxy file.
  * Config file is required
@@ -16,7 +18,7 @@
 /**
  * To make parsing from config and proxy file.
  */
-bool common(std::fstream*, Agent*);
+bool common(Agent*);
 
 /**
  * Check if a file exist.
diff --git a/include/agent/curl.h b/include/agent/connection.h
similarity index 70%
rename from include/agent/curl.h
rename to include/agent/connection.h
index 118feff971c1b8ed0a5ad9d6864ef63fd58cf5e6..bd1953cb5689d4046a75a758639c1169bd3e9347 100644
--- a/include/agent/curl.h
+++ b/include/agent/connection.h
@@ -17,14 +17,20 @@
  *      - Using libcurl to make a get request (curl/curl.h)
  */
 
-class Curl{
+class Agent; // forward declarations
+
+class Connection{
     private:
         CURL *curl; /*!< Curl object */
         CURLcode response; /*!< Response from webService */
         long httpCode = 0; /*!< Code return from webSerice (200, 404, 502 and so on) */
 
     public:
-        bool downloadAgent (std::string, std::fstream*, Agent*);
+        bool downloadAgent (std::string, Agent*, int);
+        bool getVersionByProxy(Agent*, std::string*, std::string);
+        int getInstallerNameByProxy(std::string, Agent*, std::string*);
+        void setCurlOption(std::string, Agent*, std::string*);
+        int sendJsonByProxy(Agent*, std::string, int);
 
         /** Default callback function that is necessary to make a curl request.
         *  @brief Obs:
@@ -39,6 +45,11 @@ class Curl{
              size_t written = fwrite((FILE*)ptr, size, nmemb, stream);
              return written;
         }
+
+        static size_t callback(void *contents, size_t size, size_t nmemb, void *userp) {
+            ((std::string*)userp)->append((char*)contents, size * nmemb);
+            return size * nmemb;
+        }
 };
 
 /*---------------------------------------------------------------------
diff --git a/include/agent/get.h b/include/agent/get.h
index 6504c017295a2b823667bd6bf4cc5cfb39258dcc..4c87e8a5d549d816c814a0c68e449bd100d8cfd4 100644
--- a/include/agent/get.h
+++ b/include/agent/get.h
@@ -5,7 +5,7 @@
 #include <cpr/cpr.h>
 #include <json/json.h>
 #include <agent/common.h>
-#include <agent/curl.h>
+#include <agent/connection.h>
 #include <agent/helper.h>
 #include <agent/parse_proxy_file.h>
 #include <agent/rotate_log_file.h>
@@ -21,9 +21,9 @@ const std::string url = "http://localhost:3001";
  * @brief Check case if has a new agent version available
  */
 
-int check_update(Agent*, std::fstream*);
+int check_update(Agent*);
 bool create_directories(std::string);
-bool compare_version(Agent*, std::string, std::fstream*);
-bool download(Agent*, std::fstream*, std::string);
+bool compare_version(Agent*, std::string);
+bool download(Agent*, std::string, int);
 void execute_agent(boost::filesystem::path);
-bool get_agent_installer_name(Conf*, std::string*);
+bool get_agent_installer_name(Agent*, std::string*, int);
diff --git a/include/agent/inventory.h b/include/agent/inventory.h
index f975301d2b9e9f9cb1af562a113f9e1501f84f88..e482d7c3ce3475690119a5889ed145f478996e1c 100644
--- a/include/agent/inventory.h
+++ b/include/agent/inventory.h
@@ -4,6 +4,7 @@
 #endif // __unix__
 #include <time.h>
 #include <iostream>
+#include <agent/agent.h>
 #include <agent/get_date.h>
 #include <agent/get_disks_info.h>
 #include <agent/get_distro.h>
@@ -33,4 +34,4 @@
  *      - Mac address
  */
 
-Json::Value get_inventory();
\ No newline at end of file
+Json::Value get_inventory(Agent*);
\ No newline at end of file
diff --git a/include/agent/main.h b/include/agent/main.h
index 15b85cbdbe130451a96a9df08ec70e65b1040dab..41d4938f0def45887087eaeb3956aa4a34accef1 100644
--- a/include/agent/main.h
+++ b/include/agent/main.h
@@ -6,6 +6,7 @@
 #include <agent/agent.h>
 #include <agent/agent_uninstall.h>
 #include <agent/common.h>
+#include <agent/connection.h>
 #include <agent/get.h>
 #include <agent/parse_config_file.h>
 #include <agent/parse_proxy_file.h>
@@ -31,7 +32,7 @@ namespace fs = boost::filesystem;
     std::string path_to_agent = "/opt/";  // NOLINT(runtime/string)
     //std::string path_to_agent_conf =  // NOLINT(runtime/string)
         //"/opt/agentC3SL/conf/";  // NOLINT(runtime/string)
-    std::string path_to_agent_conf = "/home/lais/Imagens/agent/conf/";
+    std::string path_to_agent_conf = "/home/teste/Imagens/agent/conf/";
 #else
     // Temporary... Define agent path
     std::string path_to_agent_tmp =  "C:\\agentC3SL\\tmp\\";
@@ -66,7 +67,7 @@ int main(int, char**);
  */
 int parse_command_line(int, char*, int*, int*, bool*);
 
-bool read_config_files(Agent*, std::fstream*);
+bool read_config_files(Agent*);
 
 /** Run agent */
 int run_agent(const sys::error_code& /*e*/, pt::ptime, bool, Agent*);
diff --git a/include/agent/parse_config_file.h b/include/agent/parse_config_file.h
index 987a5f87eb6be4c626b3c392721073fcdf419e4a..96ed99f265186a3d742e27f71241db126b455d28 100644
--- a/include/agent/parse_config_file.h
+++ b/include/agent/parse_config_file.h
@@ -36,7 +36,7 @@ class Conf{
 
     };
 
-bool parse_config_file(Agent*, std::fstream*);
+bool parse_config_file(Agent*);
 
 /** 
  * @file parse_config_file.h
diff --git a/include/agent/parse_proxy_file.h b/include/agent/parse_proxy_file.h
index 9af65c0903452b2efc91aeae85b7727f98953914..f1d65c5d9b09b0bb3f1fc9c25c81a95654322ddd 100644
--- a/include/agent/parse_proxy_file.h
+++ b/include/agent/parse_proxy_file.h
@@ -34,7 +34,7 @@ class Proxy{
         bool proxyFileIsSet() const;
     };
 
-bool parse_proxy_file(Agent*, std::fstream*);
+bool parse_proxy_file(Agent*);
 
 /** 
  * @file parse_proxy_file.h
diff --git a/include/agent/post.h b/include/agent/post.h
index 3acab3d47070b8b0f29e9126cc5e055b9c172a22..dfd9e5de0ecaab98f98c1af862cf5a192458b218 100644
--- a/include/agent/post.h
+++ b/include/agent/post.h
@@ -2,6 +2,8 @@
 #include <iostream>
 #include <cpr/cpr.h>
 #include <json/json.h>
+#include <agent/agent.h>
+#include <agent/connection.h>
 #include <agent/inventory.h>
 #include <agent/user_history.h>
 #include <agent/network_bandwidth.h>
@@ -11,6 +13,6 @@
  * @brief Collect data from hardware and send to c3sl web service
  */
 
-int send_inventory(bool, std::string);
-int send_net_bandwidth(bool, std::string);
-int send_user_history(bool, std::string);
+int send_inventory(bool, Agent *);
+int send_net_bandwidth(bool, Agent*);
+int send_user_history(bool, Agent*);
diff --git a/src/agent/agent.cpp b/src/agent/agent.cpp
index 8b7f896e8e83d924c2be84929febdc494e21f136..4028ab0a2369657a5aa6f132a60b9816d28f02f3 100644
--- a/src/agent/agent.cpp
+++ b/src/agent/agent.cpp
@@ -45,16 +45,6 @@ void Agent::setPathLogFile(std::string file) {
     this->pathLogFile = this->prefix  + file;
 }
 
-/** Set the log message
- * @brief We have a:
- * * logfile
- * .
- * that are used to saved the success, error and warning messages
-*/
-void Agent::setMessage(std::string m) {
-    this->message = m;
-}
-
 /** Set the absolute path from agent */
 void Agent::setPrefix(std::string p, int tot) {
     int i = p.size(), count = 0;
@@ -75,6 +65,10 @@ void Agent::setInstallerName(std::string i) {
     this->installerName = i;
 }
 
+void Agent::setConnection(Connection* c) {
+    this->connection = c;
+}
+
 void Agent::setConf(Conf* conf) {
     this->conf = conf;
 }
@@ -103,11 +97,6 @@ std::string Agent::getPathLogFile() const {
     return this->pathLogFile;
 }
 
-/** Return the success, error or warning message */
-std::string Agent::getMessage() const {
-    return this->message;
-}
-
 /** Return the absolute  path from agent */
 std::string Agent::getPrefix() const {
     return this->prefix;
@@ -120,6 +109,10 @@ std::string Agent::getInstallerName() const {
     return this->installerName;
 }
 
+Connection* Agent::getConnection() const {
+    return this->connection;
+}
+
 Conf* Agent::getConf() const {
     return this->conf;
 }
diff --git a/src/agent/common.cpp b/src/agent/common.cpp
index cab79e66f0809d671b56842299a7fbd2dd125754..9972d0d9a134e9215355204fbc9b86feb4575e4d 100644
--- a/src/agent/common.cpp
+++ b/src/agent/common.cpp
@@ -43,22 +43,22 @@ bool file_exist(const std::string& file) {
 /**
  * To make parsing from config and proxy file.
  */
-bool common(std::fstream* logFile, Agent* agent) {
+bool common(Agent* agent) {
     try {
         agent->prefixISet();
     } catch (const char* error) {
-        *logFile << __DATE__ + *error << std::endl;
+        agent->logFile << __DATE__ + *error << std::endl;
         return false;
     }
 
     /* Read config file and declare only valid variables */
     if (!file_exist(agent->getPathConfigFile())) {
-        *logFile << __DATE__ +
+        agent->logFile << __DATE__ +
             std::string(" - ERROR: Config file not found.") << std::endl;
         return false;
     } else {
-       if (!parse_config_file(agent, logFile)) {
-            *logFile << __DATE__ +
+       if (!parse_config_file(agent)) {
+            agent->logFile << __DATE__ +
                 std::string(" - ERROR: parse config file.") << std::endl;
             return false;
         }
@@ -66,18 +66,18 @@ bool common(std::fstream* logFile, Agent* agent) {
 
     /* Read proxy file and declare only valid variables */
     if (!file_exist(agent->getConf()->getPathProxyFile())) {
-        *logFile << __DATE__ +
+        agent->logFile << __DATE__ +
                 std::string(" - WARNING: Proxy file not found.") << std::endl;
     } else {
-        if (!parse_proxy_file(agent , logFile)) {
-            *logFile << __DATE__ +
+        if (!parse_proxy_file(agent)) {
+            agent->logFile << __DATE__ +
                 std::string(" - ERROR: parse proxy file.") << std::endl;
             return false;
         }
     }
 
     if (agent->getConf()->getWebService().size() == 0) {
-        *logFile << __DATE__ +
+        agent->logFile << __DATE__ +
                 std::string(" - ERROR: Web service url not configured.")
                                 << std::endl;
         return false;
diff --git a/src/agent/connection.cpp b/src/agent/connection.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4b458cab3828c08e29b85dd5fc17c6962d3b01b7
--- /dev/null
+++ b/src/agent/connection.cpp
@@ -0,0 +1,252 @@
+/* Copyright (C) 2004-2017 Centro de Computacao Cientifica e Software Livre
+ * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
+ *
+ * This file is part of simmc-agent
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ * USA.
+ */
+#include <agent/connection.h>
+#include <string>
+
+/** Contact webservice server to update the agent. 
+*  @brief Obs:
+*    - Not using proxy connection;
+*    - Not downloading file from https protocol;
+*    - Is a get request.
+*
+* @param url    references to webService
+* @param agent  object agent
+* @param data   json object to save success, error and warning messages
+* @param logFile  references from logfile to save success, error and warning messages
+*/
+bool Connection::downloadAgent(std::string url, Agent* agent, int option) {
+    curl = curl_easy_init();
+    if (!curl) {
+        agent->logFile << __DATE__ + std::string(" - ERROR: Curl ") +
+            std::string(" did not initialize!") << std::endl;
+        return false;
+    }
+
+    boost::system::error_code ec;
+    /** 
+     * Create a tmp directory on linux (I don't think it's the same on windows)
+     * /tmp/Agent%%%% ....
+     */
+    boost::filesystem::path tmp_dir_agent(boost::filesystem::unique_path(
+        boost::filesystem::temp_directory_path(ec) / "Agent%%%%-%%%%-%%%%"));
+
+    if (!boost::filesystem::create_directory(tmp_dir_agent, ec) || ec) {
+        agent->logFile << __DATE__ + std::string(" - ERROR: Failed to create ")
+                + std::string("a temporary directory.") << std::endl;
+        return false;
+    }
+
+    #ifdef __unix__
+        agent->setInstallerName("agent.run");
+    #else
+        agent->setInstallerName("agent.exe");
+    #endif
+
+    /* Create the agent tmp (.run) or (.exe) file into tmp_dir_agent */
+    boost::filesystem::path file_installer(tmp_dir_agent / agent->getInstallerName()); // NOLINT [whitespace/line_length]
+
+    #ifdef __unix__
+        FILE* fp = fopen(file_installer.c_str(), "wb");
+    #elif _WIN32
+        FILE* fp = fopen((const char*)file_installer.c_str(), "wb");
+    #endif
+
+    if (!fp) {
+        agent->logFile << __DATE__ + std::string(" - ERROR: Failed to ") +
+                    std::string("create file on the disk.") << std::endl;
+        return false;
+    }
+
+    curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
+    curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
+    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
+                    &Connection::callBackDownload);
+
+    if (option == 0) {
+        std::string::size_type sz; // NOLINT [runtime/int]
+        long port; // NOLINT [runtime/int]
+
+        try {
+            port = std::stol(agent->getProxy()->getPort(), &sz); // NOLINT [runtime/int]
+        } catch (std::invalid_argument& ex) {
+            port = 0;
+        }
+
+        curl_easy_setopt(curl, CURLOPT_PROXY,
+                        agent->getProxy()->getHost().c_str());
+        curl_easy_setopt(curl, CURLOPT_PROXYPORT, port);
+        curl_easy_setopt(curl, CURLOPT_PROXYUSERNAME,
+                        agent->getProxy()->getUser().c_str());
+        curl_easy_setopt(curl, CURLOPT_PROXYPASSWORD,
+                    agent->getProxy()->getPassword().c_str());
+    }
+
+    curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
+    // curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
+    curl_easy_setopt(curl, CURLOPT_FAILONERROR, true);
+    response = curl_easy_perform(curl);
+    curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
+    curl_easy_cleanup(curl);
+
+    if (httpCode == 302) {
+        agent->logFile << __DATE__ + std::string(" - ERROR: Protocol HTTPS ") +
+            std::string("not supported or disabled in libcurl.") << std::endl;
+        return false;
+    }
+
+    if (httpCode == 504) {
+        agent->logFile << __DATE__ + std::string(" - ERROR: Time out.")
+            << std::endl;
+        return false;
+    }
+
+    fclose(fp);
+
+    // run agent.run on linux
+    execute_agent(file_installer);
+
+    // remove agent tmp directory
+    boost::uintmax_t res = boost::filesystem::remove_all(tmp_dir_agent);
+    if (res < 2) {
+        agent->logFile << __DATE__ + std::string(" - WARNING: Failed ") +
+            std::string("to remove the agent tmp directory.") << std::endl;
+    }
+
+    if (response) {
+        agent->logFile << __DATE__ + std::string(" - ERROR: Failed ") +
+                    std::string("to download the agent.") << std::endl;
+        return false;
+    }
+
+    return true;
+}
+
+void Connection::setCurlOption(std::string url, Agent* agent,
+                                std::string* out) {
+    std::string::size_type sz; // NOLINT [runtime/int]
+    long port; // NOLINT [runtime/int]
+
+    try {
+        port = std::stol(agent->getProxy()->getPort(), &sz); // NOLINT [runtime/int]
+    } catch (std::invalid_argument& ex) {
+        port = 0;
+    }
+
+    curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
+    curl_easy_setopt(curl, CURLOPT_PROXY, agent->getProxy()->getHost().c_str());
+    curl_easy_setopt(curl, CURLOPT_PROXYPORT, port);
+    curl_easy_setopt(curl, CURLOPT_PROXYUSERNAME,
+                    agent->getProxy()->getUser().c_str());
+    curl_easy_setopt(curl, CURLOPT_PROXYPASSWORD,
+                agent->getProxy()->getPassword().c_str());
+    curl_easy_setopt(curl, CURLOPT_WRITEDATA, out);
+    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &Connection::callback);
+    curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
+    // curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
+    curl_easy_setopt(curl, CURLOPT_FAILONERROR, true);
+    response = curl_easy_perform(curl);
+    curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
+    curl_easy_cleanup(curl);
+}
+
+bool Connection::getVersionByProxy(Agent* agent, std::string *version,
+                                std::string url) {
+    struct curl_slist *headers = NULL;
+    headers = curl_slist_append(headers, "Accept: application/json");
+    headers = curl_slist_append(headers, "Content-Type: application/json");
+    headers = curl_slist_append(headers, "charsets: utf-8");
+
+    curl = curl_easy_init();
+
+    curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
+
+    this->setCurlOption(url, agent, version);
+    if (httpCode == 200)
+        return true;
+    else
+        return false;
+}
+
+int Connection::getInstallerNameByProxy(std::string url, Agent* agent,
+                            std::string* filename) {
+    curl = curl_easy_init();
+    this->setCurlOption(url, agent, filename);
+    return httpCode;
+}
+
+int Connection::sendJsonByProxy(Agent* agent, std::string json, int opt) {
+    std::string::size_type sz; // NOLINT [runtime/int]
+    long port; // NOLINT [runtime/int]
+
+    try {
+        port = std::stol(agent->getProxy()->getPort(), &sz); // NOLINT [runtime/int]
+    } catch (std::invalid_argument& ex) {
+        port = 0;
+    }
+
+    std::string base_url = agent->getConf()->getWebService();
+
+    struct curl_slist *headers = NULL;
+    headers = curl_slist_append(headers, "Accept: application/json");
+    headers = curl_slist_append(headers, "Content-Type: application/json");
+    headers = curl_slist_append(headers, "charsets: utf-8");
+
+    // opt == 1 {send inventory}
+    // opt = 2 {send net bandwidth}
+    // otherwise, {send user history}
+    if (opt == 1)
+        base_url = base_url + std::string("/api/agent/collect/inventory");
+    else if (opt == 2)
+        base_url = base_url + std::string("/api/agent/collect/net_usage");
+    else
+        base_url = base_url + std::string("/api/agent/collect/user_history");
+
+    curl_global_init(CURL_GLOBAL_ALL);
+    curl = curl_easy_init();
+    curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
+    curl_easy_setopt(curl, CURLOPT_URL, base_url.c_str());
+    curl_easy_setopt(curl, CURLOPT_PROXY, agent->getProxy()->getHost().c_str());
+    curl_easy_setopt(curl, CURLOPT_PROXYPORT, port);
+    curl_easy_setopt(curl, CURLOPT_PROXYUSERNAME,
+                    agent->getProxy()->getUser().c_str());
+    curl_easy_setopt(curl, CURLOPT_PROXYPASSWORD,
+                agent->getProxy()->getPassword().c_str());
+    curl_easy_setopt(curl, CURLOPT_POST, 1);
+    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json.c_str());
+    curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
+    // curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
+    curl_easy_setopt(curl, CURLOPT_FAILONERROR, true);
+    response = curl_easy_perform(curl);
+    curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
+    curl_easy_cleanup(curl);
+
+    return httpCode;
+
+}
+
+
+/** 
+ * @file curl.cpp
+ * @brief This file has implementation from Curl's method and the purpose is to make a get request to web 
+ * service and download the agent zip file
+ *  - Obs
+ *      - Using libcurl to make a get request (curl/curl.h)
+ */
diff --git a/src/agent/curl.cpp b/src/agent/curl.cpp
deleted file mode 100644
index c9fb80bc192a88e0ff5795f9bea370d306725181..0000000000000000000000000000000000000000
--- a/src/agent/curl.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-/* Copyright (C) 2004-2017 Centro de Computacao Cientifica e Software Livre
- * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
- *
- * This file is part of simmc-agent
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
- * USA.
- */
-#include <agent/curl.h>
-#include <string>
-
-/** Contact webservice server to update the agent. 
-*  @brief Obs:
-*    - Not using proxy connection;
-*    - Not downloading file from https protocol;
-*    - Is a get request.
-*
-* @param url    references to webService
-* @param agent  object agent
-* @param data   json object to save success, error and warning messages
-* @param logFile  references from logfile to save success, error and warning messages
-*/
-bool Curl::downloadAgent(std::string url, std::fstream* logFile,
-                            Agent* agent) {
-    curl = curl_easy_init();
-    if (!curl) {
-        agent->setMessage(__DATE__ + std::string(" - ERROR: Curl ") +
-            std::string(" did not initialize!"));
-        *logFile << agent->getMessage() << std::endl;
-        return false;
-    }
-
-    boost::system::error_code ec;
-    /** 
-     * Create a tmp directory on linux (I don't think it's the same on windows)
-     * /tmp/Agent%%%% ....
-     */
-    boost::filesystem::path tmp_dir_agent(boost::filesystem::unique_path(
-        boost::filesystem::temp_directory_path(ec) / "Agent%%%%-%%%%-%%%%"));
-
-    if (!boost::filesystem::create_directory(tmp_dir_agent, ec) || ec) {
-        agent->setMessage(__DATE__ + std::string(" - ERROR: Failed to create ")
-                + std::string("a temporary directory."));
-        *logFile << agent->getMessage() << std::endl;
-        return false;
-    }
-
-    #ifdef __unix__
-        agent->setInstallerName("agent.run");
-    #else
-        agent->setInstallerName("agent.exe");
-    #endif
-
-    /* Create the agent tmp (.run) or (.exe) file into tmp_dir_agent */
-    boost::filesystem::path file_installer(tmp_dir_agent / agent->getInstallerName()); // NOLINT [whitespace/line_length]
-
-    #ifdef __unix__
-        FILE* fp = fopen(file_installer.c_str(), "wb");
-    #elif _WIN32
-        FILE* fp = fopen((const char*)file_installer.c_str(), "wb");
-    #endif
-
-    if (!fp) {
-        agent->setMessage(__DATE__ + std::string(" - ERROR: Failed to ") +
-                    std::string("create file on the disk."));
-        *logFile << agent->getMessage() << std::endl;
-        return false;
-    }
-
-    curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
-    curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
-    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &Curl::callBackDownload);
-    curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
-    curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
-    curl_easy_setopt(curl, CURLOPT_FAILONERROR, true);
-    response = curl_easy_perform(curl);
-    curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
-    curl_easy_cleanup(curl);
-
-    if (httpCode == 302) {
-        agent->setMessage(__DATE__ + std::string(" - ERROR: Protocol HTTPS ") +
-                    std::string("not supported or disabled in libcurl."));
-        *logFile << agent->getMessage() << std::endl;
-        return false;
-    }
-
-    if (httpCode == 504) {
-        agent->setMessage(__DATE__ +
-        std::string(" - ERROR: Time out."));
-        *logFile << agent->getMessage() << std::endl;
-        return false;
-    }
-
-    fclose(fp);
-
-    // run agent.run on linux
-    execute_agent(file_installer);
-
-    // remove agent tmp directory
-    boost::uintmax_t res = boost::filesystem::remove_all(tmp_dir_agent);
-    if (res < 2) {
-        agent->setMessage(__DATE__ + std::string(" - WARNING: Failed ") +
-                    std::string("to remove the agent tmp directory."));
-        *logFile << agent->getMessage() << std::endl;
-    }
-
-    if (response) {
-        agent->setMessage(__DATE__ + std::string(" - ERROR: Failed ") +
-                    std::string("to download the agent."));
-        *logFile << agent->getMessage() << std::endl;
-        return false;
-    }
-
-    return true;
-}
-
-/** 
- * @file curl.cpp
- * @brief This file has implementation from Curl's method and the purpose is to make a get request to web 
- * service and download the agent zip file
- *  - Obs
- *      - Using libcurl to make a get request (curl/curl.h)
- */
diff --git a/src/agent/get.cpp b/src/agent/get.cpp
index 4de5c0bd2d3a6eba623846e3a98f7ca0b91be59c..1f934ac0a2e185f975d1800ae62f7f32887ac2d3 100644
--- a/src/agent/get.cpp
+++ b/src/agent/get.cpp
@@ -30,56 +30,40 @@
   * Case if needed, making download from agent zipfile.
   */
 
-int check_update(Agent* agent, std::fstream* logFile) {
+int check_update(Agent* agent) {
     std::string version;
     Json::Reader reader;
     Json::Value version_json;
     Json::FastWriter fastWriter;
+    int option = 1;
 
     /* Contact webservice server to get client version. */
     auto p = cpr::Get(cpr::Url{agent->getConf()->getWebService() +
                                 "/api/agent/version"},
               cpr::Header{{"content-type", "application/json"}});
 
-    /* Check error with connection */
-    if (p.status_code == 502)
-        *logFile << __DATE__ << "- ERROR: The proxy server received an"
-                <<  " invalid response from server." << std::endl;
+    // Check error with connection
+    if (p.status_code != 200) {
+        option = 0;
+        // Case if not connected before, try it with proxy
+        std::string web_service = agent->getConf()->getWebService() +
+                        std::string("/api/agent/version");
+        if (!agent->getConnection()->getVersionByProxy(agent, &version,
+                                                web_service)) {
+            agent->logFile << __DATE__ << " - ERROR: Couldn't get current " <<
+                    "version from simmc web service." << std::endl;
+        }
+    } else {
+        version = p.text;
+    }
 
-    // p.text - response from api
-    reader.parse(p.text, version_json, false);
+       // p.text - response from api
+    reader.parse(version, version_json, false);
     version = fastWriter.write(version_json["version"]);
-
     boost::regex re("(\")|(\n)");
     version = boost::regex_replace(version, re, "");
 
-    // Case if not connected before, try it with proxy
-    if (p.status_code != 200) {
-        // try send via proxy
-        auto p = cpr::Get(cpr::Url{agent->getConf()->getWebService() + "/api"},
-              cpr::Proxies{{"http", agent->getProxy()->getHost()}},
-              cpr::Parameters{{"agent", "version"}},
-              cpr::Header{{"content-type", "application/json"}});
-
-        /* Check error with connection */
-        if (p.status_code == 502)
-            *logFile << __DATE__ << " - ERROR: The proxy server received an"
-                    << "invalid response from server." << std::endl;
-
-        reader.parse(p.text, version_json, false);
-        version = fastWriter.write(version_json["version"]);
-        version = boost::regex_replace(version, re, "");
-
-    }
-
-    // Case if none of them get rigth, set log file
-    if (p.status_code != 200) {
-        *logFile << __DATE__ << " - ERROR: Try to connect with server"
-                            << std::endl;
-        return false;
-    }
-
-    if (agent->getConf()->getVersion() == "0.0.0") {
+    if (agent->getConf()->getVersion() == "0.0.0" && version != "") {
         // open version.json file and update to current version
         Json::Value config;
         Json::Reader reader;
@@ -102,21 +86,23 @@ int check_update(Agent* agent, std::fstream* logFile) {
     }
 
     /* Case version are different, then make the download */
-    if (compare_version(agent, version, logFile)) {
+    if (compare_version(agent, version)) {
         /* Case not download, return false */
         std::string filename;
-        if (get_agent_installer_name(agent->getConf(), &filename)) {
-            if (download(agent, logFile, filename)) {
-                *logFile << __DATE__ << " - SUCCESS: Update process " <<
+        if (get_agent_installer_name(agent, &filename, option)) {
+            if (download(agent, filename, option)) {
+                agent->logFile << __DATE__ << " - SUCCESS: Update process " <<
                         "terminated successfully." << std::endl;
-                logFile->close();
+                agent->logFile.close();
                 return true;
             }
         }
-        *logFile << __DATE__ << " - ERROR: Failed to update agent."
+        agent->logFile << __DATE__ << " - ERROR: Couldn't get installer " <<
+                    "name from simmc web service." << std::endl;
+        agent->logFile << __DATE__ << " - ERROR: Failed to update agent."
                         << std::endl;
     }
-    logFile->close();
+    agent->logFile.close();
     return false;
 }
 
@@ -126,29 +112,29 @@ int check_update(Agent* agent, std::fstream* logFile) {
  * <br>
  * Otherwise, return false.
  */
-bool compare_version(Agent *agent, std::string version,
-                        std::fstream* logFile) {
+bool compare_version(Agent *agent, std::string version) {
     if (!strcmp(version.c_str(), "")) {
-        *logFile << __DATE__ + std::string(" - ERROR: Server returned an") +
-                    std::string(" empty version string.") << std::endl;
+        agent->logFile << __DATE__ + std::string(" - ERROR: Server returned") +
+                    std::string(" an empty version string.") << std::endl;
         return false;
-    } else if (strcmp(version.c_str(), agent->getConf()->getVersion().c_str())) { // NOLINT [whitespace/line_length]
-        *logFile << __DATE__ +
+    } else if (strcmp(version.c_str(),agent->getConf()->getVersion().c_str())) { // NOLINT [whitespace/line_length]
+        agent->logFile << __DATE__ +
             std::string(" - WARNING: Client version out-of-date.") +
             std::string(" Update client.") << std::endl;
         return true;
     } else {
-        *logFile << __DATE__ +
+        agent->logFile << __DATE__ +
         std::string(" - WARNING: Client is already updated.")<< std::endl;
         return false;
     }
 }
 
 /* Contact webservice server to request a agent installer. */
-bool get_agent_installer_name(Conf* conf, std::string* filename) {
+bool get_agent_installer_name(Agent* agent, std::string* filename, int opt) {
     Json::FastWriter fastWriter;
     Json::Value filename_json;
     Json::Reader reader;
+    int status_code;
 
     #ifdef __linux__
         std::string os = "linux";
@@ -156,16 +142,28 @@ bool get_agent_installer_name(Conf* conf, std::string* filename) {
         std::string os = "windows";
     #endif
 
-    auto p = cpr::Get(cpr::Url{conf->getWebService() + "/api/agent/install/" + os + "/" + std::to_string(2)}, // NOLINT [whitespace/line_length]
+    std::string ws = agent->getConf()->getWebService()
+                     + std::string("/api/agent/install/")
+                     + std::string(os) + std::string("/")
+                     + std::to_string(agent->getConf()->getIdPoint());
+
+    if (opt == 1) {
+        auto p = cpr::Get(cpr::Url{ws}, // NOLINT [whitespace/line_length]
                 cpr::Header{{"content-type", "application/json"}});
+        status_code = p.status_code;
+        *filename = p.text;
+    } else {
+        status_code = agent->getConnection()->getInstallerNameByProxy(ws, agent, filename); // NOLINT [whitespace/line_length]
+    }
 
-    if (p.status_code == 200) {
+    if (status_code == 200) {
         // p.text - response from api
-        reader.parse(p.text, filename_json, false);
+        reader.parse(*filename, filename_json, false);
         *filename = fastWriter.write(filename_json["filename"]);
 
         boost::regex re("(\")|(\n)");
         *filename = boost::regex_replace(*filename, re, "");
+
         return true;
     } else {
         return false;
@@ -175,13 +173,15 @@ bool get_agent_installer_name(Conf* conf, std::string* filename) {
  /**
  * To make agent download.
  * Curl library is used to make a webService request to get agent zipfile.
+ * option -> indicate proxy or not
+ *              0 -> proxy
+ *              1 -> not proxy
  */
-bool download(Agent* agent, std::fstream* logFile, std::string filename) {
-    Curl curl;
+bool download(Agent* agent, std::string filename, int option) {
     std::string web_service = agent->getConf()->getWebService() +
                 std::string("/install/") +
                 std::string(filename);
-    if (curl.downloadAgent(web_service, logFile, agent))
+    if (agent->getConnection()->downloadAgent(web_service, agent, option))
         return true;
     return false;
 }
diff --git a/src/agent/inventory.cpp b/src/agent/inventory.cpp
index 6c57660ab412918f56ac70118b7e241c3baa0d67..45ab5a4b66a8e974604795bcaee325e963d0c266 100644
--- a/src/agent/inventory.cpp
+++ b/src/agent/inventory.cpp
@@ -40,11 +40,9 @@ extern std::string path_to_agent_tmp;
 extern std::string path_to_agent;
 extern std::string path_to_agent_conf;
 
-Json::Value get_inventory() {
+Json::Value get_inventory(Agent* agent) {
     Json::Value inv;
     Json::Reader reader;
-    Json::Value conf;
-    std::ifstream agent_conf;
     // os info
 
     #ifdef __linux__
@@ -52,12 +50,8 @@ Json::Value get_inventory() {
         uname(&sysinfo);
     #endif
 
-    // change path (current)
-    agent_conf.open(path_to_agent_conf + "datasid-conf.json",
-         std::ifstream::binary);
-    reader.parse(agent_conf, conf , false);
-    inv["data_inventory"]["id_point"] = conf["idPoint"];
-    inv["data_inventory"]["agent_version"] = conf["version"];
+    inv["data_inventory"]["id_point"] = agent->getConf()->getIdPoint();
+    inv["data_inventory"]["agent_version"] = agent->getConf()->getVersion();
 
 
     // OS type
diff --git a/src/agent/main.cpp b/src/agent/main.cpp
index 30b8da6a173928500ec7db8eb2717851eefde9b6..bd26082b6cb66cdd389c7be8392777407eed2302 100644
--- a/src/agent/main.cpp
+++ b/src/agent/main.cpp
@@ -24,23 +24,23 @@
 
 /** Run agent */
 int run_agent(const sys::error_code& /*e*/, pt::ptime begin,
-            bool print, Agent* agent, std::fstream* logFile) {
+            bool print, Agent* agent) {
     pt::ptime now;
     now = pt::second_clock::local_time();
     pt::time_duration t3 = now - begin;
-    bool parse = read_config_files(agent, logFile);
+    bool parse = read_config_files(agent);
     if (agent_send_net_band && (t3.minutes() % 5 == 0 )) {
         if (parse)
-            send_net_bandwidth(print, agent->getConf()->getWebService());
+            send_net_bandwidth(print, agent);
     }
     if ((t3.hours() % 24 == 0) && (t3.minutes() %60 == 0  )) {
         // make parse from config files and check update
         if (parse) {
             if (agent_send_inventory) {
-                send_inventory(print, agent->getConf()->getWebService());
+                send_inventory(print, agent);
             }
             if (agent_send_user_hist) {
-                send_user_history(print, agent->getConf()->getWebService());
+                send_user_history(print, agent);
             }
         }
     }
@@ -144,7 +144,7 @@ int parse_command_line(int ac, char* av[], int *increment, int *lim,
     return(0);
 }
 
-bool read_config_files(Agent* agent, std::fstream* logFile) {
+bool read_config_files(Agent* agent) {
     /* Set conf's file */
     agent->setPathConfDir("/conf");
     agent->setPathConfigFile("/conf/datasid-conf.json");
@@ -153,13 +153,13 @@ bool read_config_files(Agent* agent, std::fstream* logFile) {
     agent->setPathLogFile("datasid-agent.log");
 
     /* run common.cpp to make parse from config and proxy file */
-    if (common(logFile, agent)) {
+    if (common(agent)) {
         rotate_log_file(agent);
-        *logFile << __DATE__ << " - Agent started." << std::endl;
-        *logFile << __DATE__ << " - Start of update process execution."
+        agent->logFile  << __DATE__ << " - Agent started." << std::endl;
+        agent->logFile << __DATE__ << " - Start of update process execution."
                     << std::endl;
 
-        check_update(agent, logFile);
+        check_update(agent);
         return (true);
     }
 
@@ -173,16 +173,18 @@ bool read_config_files(Agent* agent, std::fstream* logFile) {
  */
 int main(int argc, char* argv[]) {
     Agent agent;
+    Connection connection;
     Conf conf;
     Proxy proxy;
     Rotate rotate;
+    agent.setConnection(&connection);
     agent.setConf(&conf);
     agent.setProxy(&proxy);
 
     /* Set agent prefix (agent folder) */
     agent.setPrefix(__FILE__, 3);
     agent.setPathLogFile("/log/datasid-agent.log");
-    std::fstream logFile(agent.getPathLogFile().c_str(), std::fstream::app);
+    agent.logFile.open(agent.getPathLogFile().c_str(), std::fstream::app);
 
     int increment = 0;
     int lim = 1;
@@ -199,16 +201,16 @@ int main(int argc, char* argv[]) {
      * web service base url to send inventory, net bandwidth 
      * and user history
      */
-    if (read_config_files(&agent, &logFile)) {
+    if (read_config_files(&agent)) {
 
         if (agent_send_inventory) {
-          send_inventory(print, agent.getConf()->getWebService());
+          send_inventory(print, &agent);
         }
         if (agent_send_net_band) {
-          send_net_bandwidth(print, agent.getConf()->getWebService());
+          send_net_bandwidth(print, &agent);
         }
         if (agent_send_user_hist) {
-          send_user_history(print, agent.getConf()->getWebService());
+          send_user_history(print, &agent);
         }
         if (agent_send_database) {
           // get database for PInSIS
@@ -223,7 +225,7 @@ int main(int argc, char* argv[]) {
     while (i < lim) {
       asio::io_service io;
       asio::deadline_timer t(io, pt::seconds(60));
-      t.async_wait(boost::bind(run_agent, pholders::error, begin, print, &agent, &logFile)); // NOLINT [whitespace/line_length]
+      t.async_wait(boost::bind(run_agent, pholders::error, begin, print, &agent)); // NOLINT [whitespace/line_length]
       io.run();
       i += increment;
     }
diff --git a/src/agent/parse_config_file.cpp b/src/agent/parse_config_file.cpp
index eb10617aff6172fa78320beb91924c8a80b05c82..b0601b4574578fe15af4f98cb9ac1de8050062f0 100644
--- a/src/agent/parse_config_file.cpp
+++ b/src/agent/parse_config_file.cpp
@@ -112,12 +112,12 @@ bool set_conf_object(Agent* agent, std::map<std::string,
 }
 
 /** Read config file and make the parse to conf object */
-bool parse_config_file(Agent* agent, std::fstream* logFile) {
+bool parse_config_file(Agent* agent) {
     std::map<std::string, std::string> content;
 
     if (read_file(agent->getPathConfigFile(), &content)) {
         if (!set_conf_object(agent, &content)) {
-            *logFile << __DATE__ + std::string(" - ERROR: to parse") +
+            agent->logFile << __DATE__ + std::string(" - ERROR: to parse") +
                     std::string(" variables from config file.") << std::endl;
             return false;
         }
diff --git a/src/agent/parse_proxy_file.cpp b/src/agent/parse_proxy_file.cpp
index e9c48e4d422de3e2dc7f452eb5d35e37d3051a5a..a98e4d805966a19ccefa4583802a60191d239386 100644
--- a/src/agent/parse_proxy_file.cpp
+++ b/src/agent/parse_proxy_file.cpp
@@ -93,14 +93,14 @@ bool set_proxy_object(Agent* agent, std::map<std::string,
 }
 
 /** Read proxy file and make the parse to proxy object */
-bool parse_proxy_file(Agent* agent, std::fstream* logFile) {
+bool parse_proxy_file(Agent* agent) {
     std::map<std::string, std::string> content;
 
     if (read_file(agent->getConf()->getPathProxyFile(), &content)) {
         if (!set_proxy_object(agent, &content)) {
-            agent->setMessage(__DATE__ +
-                std::string(" - ERROR: to parse variables from proxy file."));
-            *logFile <<  agent->getMessage() << std::endl;
+            agent->logFile << __DATE__ + std::string(" - ERROR: to parse ") +
+                            std::string("variables from proxy file.")
+                << std::endl;
             return false;
         }
     }
diff --git a/src/agent/post.cpp b/src/agent/post.cpp
index c5ff982e2d1a5bcfe95c020a5bea862b9ad3ad24..6489c9330f37fe942b4bbb9c684adff7ed8c4c40 100644
--- a/src/agent/post.cpp
+++ b/src/agent/post.cpp
@@ -29,8 +29,9 @@
  *    - Send inventory json object;
  *    - Cpr wrapper library - to make request to webService;
  */
-int send_inventory(bool print, std::string base_url) {
-    Json::Value inventory = get_inventory();
+int send_inventory(bool print, Agent* agent) {
+    std::string base_url = agent->getConf()->getWebService();
+    Json::Value inventory = get_inventory(agent);
     Json::FastWriter fastWriter;
 
     if (print == true) {
@@ -47,6 +48,10 @@ int send_inventory(bool print, std::string base_url) {
 
     if (p.status_code == 200)
         return 1;
+    else
+        if (agent->getConnection()->sendJsonByProxy(agent,
+                fastWriter.write(inventory), 1) == 200)
+            return 1;
 
     return 0;
 }
@@ -59,7 +64,8 @@ int send_inventory(bool print, std::string base_url) {
  *    - Send net json object;
  *    - Cpr wrapper library - to make request to webService;
  */
-int send_net_bandwidth(bool print, std::string base_url) {
+int send_net_bandwidth(bool print, Agent* agent) {
+    std::string base_url = agent->getConf()->getWebService();
     Json::Value net =  get_net_bandwidth();
     Json::FastWriter fastWriter;
 
@@ -77,6 +83,10 @@ int send_net_bandwidth(bool print, std::string base_url) {
 
     if (p.status_code == 200)
         return 1;
+    else
+        if (agent->getConnection()->sendJsonByProxy(agent,
+                fastWriter.write(net), 2) == 200)
+            return 1;
 
     return 0;
 }
@@ -89,7 +99,8 @@ int send_net_bandwidth(bool print, std::string base_url) {
  *    - Send u_h json object;
  *    - Cpr wrapper library - to make request to webService;
  */
-int send_user_history(bool print, std::string base_url) {
+int send_user_history(bool print, Agent* agent) {
+    std::string base_url = agent->getConf()->getWebService();
     Json::Value u_h;
     Json::FastWriter fastWriter;
 
@@ -106,9 +117,12 @@ int send_user_history(bool print, std::string base_url) {
                       cpr::Body{fastWriter.write(u_h)},
                       cpr::Header{{"content-type", "application/json"}});
 
-    if (p.status_code == 200) {
+    if (p.status_code == 200)
         return 1;
-    }
+    else
+        if (agent->getConnection()->sendJsonByProxy(agent,
+                fastWriter.write(u_h), 3) == 200)
+            return 1;
 
     return 0;
 }
diff --git a/src/agent/rotate_log_file.cpp b/src/agent/rotate_log_file.cpp
index aa0b7805d8a332dd576166042bf398d01c84e9b8..054116d7bf2468fbadbfa537ee36f0e72810d930 100644
--- a/src/agent/rotate_log_file.cpp
+++ b/src/agent/rotate_log_file.cpp
@@ -79,13 +79,9 @@ bool Rotate::logDirIsSet() {
 void Rotate::createLogfile(Agent* agent) {
     std::fstream file(this->getLogfileName().c_str(), std::fstream::app);
     if (file.is_open()) {
-        agent->setMessage(__DATE__ + std::string(" - SUCCESS: ") +
-                    std::string(" Rotate logfile."));
-        file << agent->getMessage() << std::endl;
+        file << __DATE__ + std::string(" - SUCCESS: Rotate logfile.")
+                << std::endl;
         file.close();
-    } else {
-        agent->setMessage(__DATE__ + std::string(" - ERROR: ") +
-                    std::string(" Logfile cannot be created."));
     }
 }
 
@@ -144,18 +140,14 @@ void rotate_log_file(Agent* agent) {
             if (logFile.is_open()) {
                 if (remove((agent->getPrefix() +
                     std::string("/log/datasid-agent.1.log")).c_str()) != 0) {
-                    agent->setMessage(__DATE__ + std::string(" - ERROR: ")
-                        + std::string("Failed to remove logFile at rotate")
-                        + std::string(" logfile function."));
-                    logFile << agent->getMessage() << std::endl;
+                    logFile << __DATE__ + std::string(" - ERROR: ") +
+                            std::string("Failed to remove logFile at rotate") +
+                            std::string(" logfile function.") << std::endl;
                 } else {
-                    agent->setMessage(__DATE__ + std::string(" - SUCCESS: ") +
-                                    std::string("Logfile removed."));
-                    logFile << agent->getMessage() << std::endl;
-
-                    agent->setMessage(__DATE__ + std::string(" - SUCCESS: ") +
-                        std::string(" Rotate logfile."));
-                    logFile << agent->getMessage() << std::endl;
+                    logFile << __DATE__ + std::string(" - SUCCESS: logfile ") +
+                            std::string("removed.") << std::endl;
+                    logFile << __DATE__ + std::string(" - SUCCESS: Rotate ") +
+                            std::string("logfile.") << std::endl;
                     rotate.renameFile(agent);
                 }
                 logFile.close();
diff --git a/test/returnTest.bats b/test/returnTest.bats
index f23d9f8cc76616d2be91a192abc2ee51fb179dba..92f95b49d8d6f9bf328a77473086e92ea5e8ac59 100755
--- a/test/returnTest.bats
+++ b/test/returnTest.bats
@@ -94,8 +94,6 @@ function id_point() {
 }
 
 setup() {
-    ../agent-1234.run  --quiet
-    cat /opt/agentC3SL/conf/datasid-conf.json 
     /opt/agentC3SL/agent-v* --print --once | head -n -1  > export.json
     pt1=$(cat export.json | head -n -9)
     echo $pt1 > inventory.json
@@ -118,11 +116,6 @@ teardown() {
     [ "$status" -eq 0 ]
 }
 
-@test "Web Service" {
-    run web_service
-    [ "$status" -eq 0 ]
-}
-
 @test "host" {
     run host
     [ "$status" -eq 0 ]
@@ -202,3 +195,8 @@ teardown() {
     run processor
     [ "$status" -eq 0 ]
 }
+
+@test "Web Service" {
+    run web_service
+    [ "$status" -eq 0 ]
+}