Node.js Http post request on aws lambda Socket Hang up
<pre><code>var http = require('http');
exports.handler = function(event, context) {

  var headers = {
      'content-type': 'application/x-www-form-urlencoded'
  }
  var options = {
    host: 'stage.wings.com',
    path:'/test-lambda',
    form: {
     'days':'3'
    },
    headers:headers
  };
  console.log(options);

  var req = http.request(options, function(response) {
      // Continuously update stream with data
      var body = '';
      response.on('data', function(d) {
          body += d;
      });
      response.on('end', function() {
          // Data reception is done, do whatever with it!
          var parsed = JSON.parse(body);
          console.log("success");
          console.log(parsed);
      });
  });
  // Handler for HTTP request errors.
  req.on('error', function (e) {
      console.error('HTTP error: ' + e.message);
      completedCallback('API request completed with error(s).');
  });
};
</code></pre>

<p>my node version : v0.10.25
If i execute on file it gives HTTP error: socket hang up
From aws lambda if i run this function it throws error</p>

<p>Lambda error:2016-10-09T23:11:17.200Z  89f2146f-8e75-11e6-9219-b9b32aa0a768  Error: socket hang up
    at createHangUpError (_http_client.js:200:15)
    at Socket.socketOnEnd (_http_client.js:285:23)
    at emitNone (events.js:72:20)
    at Socket.emit (events.js:166:7)
    at endReadableNT (_stream_readable.js:905:12)
    at nextTickCallbackWith2Args (node.js:437:9)
    at process._tickDomainCallback (node.js:392:17)</p>