1

I'm using Node.js (and Express, if that matters) to act as a proxy, using http-proxy, like this:

var routingProxy = httpProxy.createServer();

app.use('/api', function (req, res) {
    // ... calculate host and port

  var target = "http://" + host + ":" + port + req.url;
  console.log("proxying starting");
  routingProxy.proxyRequest(req, res, { target: target} );
  console.log('proxy succeeded');
});

Which works fine, when it works. However, if the target server doesn't respond properly, the whole Node instance ends, saying

proxy starting
proxy succeeded

Error: connect ETIMEDOUT
at errnoException (net.js:904:11)
at Object.afterConnect [as oncomplete] (net.js:895:19)

And then the program exits!

The problem is surprisingly obdurate over every change I have thought of.

Michael Lorton
  • 43,060
  • 26
  • 103
  • 144
  • what you mean with "target server doesn't respond properly" you mean no response or bad characters response or timeout or what ? – Eslam Salem Mahmoud Jan 10 '15 at 08:38
  • @EslamSalemMahmoud - As you can see, I am getting a timeout. The underlying problem is that the server is on a VPN and if a I forget to join the VPN, the firewall block the packets from my proxy. I assume if the server were simply down, I would see the same effect. – Michael Lorton Jan 10 '15 at 14:29

0 Answers0