title: Socket hang up when using axios.get, but not when using https.get
body: <p>To the best of my knowledge, I am doing the same thing using 2 different approaches:</p>
  
  <pre><code>const https = require("https");
  const axios = require("axios");
  
  let httpsAgent = new https.Agent({rejectUnauthorized: false});
  
  axios.get(`https://${hostname}:${port}${path}`, {httpsAgent})
      .then((data) =&gt; { console.log("axios success: " + data.substr(0, 100)); })
      .catch((error) =&gt; { console.log("axios error: " + error); });
  
  let data = "";
  https.get({ hostname, path, port, agent: httpsAgent },
      (response) =&gt; {
          response.on("data", (chunk) =&gt; { data += chunk; });
          response.on("end", () =&gt; { console.log("https success: " + data.substr(0, 100)); });
      })
      .on("error", (error) =&gt; { console.log("https error: " + error); });
  </code></pre>
  
  <p>When I run this code, i get 2 different outcomes:</p>
  
  <pre><code>PS C:\Users\me&gt; .\node\node.exe .\generate-test-data.js
  axios error: Error: socket hang up
  https success: [{"cool":"data"...
  </code></pre>
  
  <p>What is going on here?  I have a feeling it has to do with asynchronicity, but not quite sure how...  Can somebody give me a hint as to how/why these 2 behaviors are different?</p>