title: Nodejs server communicate with two network interface cards
body: <p>Is it possible with a nodejs server to have it receive a message on one network interface and then output an HTTP request on a different network interface?</p>
  
  <p>The scenario:
  I have a device on a local network and I want the server to be able to receive data from that and format it into a request to update a third party web app.
  I have confirmed that I am receiving the local message correctly, and I have confirmed that the format of the HTTP request should work using fiddler, but somewhere between the two parts I am having an issue.
  I get a "socket hang up" error at the moment.</p>
  
  <p>Thanks in advance</p>
  
  <p><strong>Edit:</strong>
  Below is my server code. I have specified IP addresses for the incoming and outgoing messages, but I still get a socket hang up error. Can anyone spot anything else which could be causing this issue? <br>
  I am wondering if I need to do something differently for a secure connection? (it is a https URL) </p>
  
  <pre><code>var url = require("url");
  var http = require('http');
  
  
  http.createServer(function (request,response) {
      var theUrl = url.parse(request.url);
      console.log(theUrl);
      var timeline = {   // Data to be sent to external web service
          channel: "#test",
          username: "Slash",
          icon_emoji: ":smirk_cat:",
          text: "Timeline Started: " + theUrl.path
      };
      var data = JSON.stringify(timeline)
  
      var options = {
          host: "example.com",
          path: "/path/to/web/service",
          localAddress: '172.20.1.53', // IP address of outgoing NIC
          method: 'POST',
          port: "443",
          headers: {
              'Content-Type': 'application/json',
              'Content-Length': Buffer.byteLength(data),
          }
      };
  
      var req = http.request(options, function(res){
          res.on('data', function(resp) {
              console.log(resp)
          });
      });
      req.on('error', function(err) {
          console.log("ERROR: " + err.message);
      });
      req.write(data);
      console.log(req);
      req.end();
  }).listen(801, '172.30.2.92'); // IP address of incoming NIC 
  </code></pre>