http-party / node-http-proxy

A full-featured http proxy for node.js
https://github.com/http-party/node-http-proxy
Other
13.95k stars 1.98k forks source link

ETIMEDOUT #776

Open mike-aungsan opened 9 years ago

mike-aungsan commented 9 years ago

{ [Error: connect ETIMEDOUT] code: 'ETIMEDOUT', errno: 'ETIMEDOUT', syscall: 'connect' }

var http  = require('http'),
    httpProxy = require('http-proxy');

var proxy = httpProxy.createProxyServer({
    xfwd    : false,
    localAddress : '192.168.0.11',
    target  : 'http://10.4.64.124:80/service'
});

proxy.listen(80);

proxy.on('error', function(err, req, res) {
    console.log('proxy error');
    console.log(err);   console.log();
});

proxy.on('proxyRes', function(proxyRes, req, res) {
    console.log('proxyRes');
    console.log(JSON.stringify(proxyRes.headers, true, 2));   console.log();
});

proxy.on('open', function (proxySocket) {

});

proxy.on('close', function (req, socket, head) {
    // view disconnected websocket connections
    console.log('Client disconnected');
});
jcrugzz commented 9 years ago

@mike-aungsan this is not a bug, the endpoint you were proxying to timed out and it was logged exactly how you expected in the code. You may want to handle the error in these cases to your client via something like this.

If you have an actual question or concern please note that when you submit an issue.

mike-aungsan commented 9 years ago

It was working fine and it stop working. The issue might come from dependencies or from the update version.

Another concern that I have is that, there is http_proxy in the network env. By default, all the http request are routed tho http_proxy. But the target host is not behind proxy. So the target host is in no_proxy list and also in browser ignore proxy list.

In this case, my guest is that http-proxy is ignore no_proxy list and ignore proxy list.

P.S Not good at writing. Hope you get it.

jcrugzz commented 9 years ago

@mike-aungsan Can you answer these questions for me?

  1. What version did you update from?
  2. What dependencies did you update?

http-proxy does not read anything from the environment when making its proxy decisions. You provide the target to it explicitly. If there are cases that require http_proxy env variable, you will need to use something like node-tunnel, but if it worked before, idk what to tell you with the information you have given.

wmanriques commented 9 years ago

I have a similar an error, I can see this since I updated to NodeJS4, the proxy sometimes returns data and other times this returns { [Error: connect ETIMEDOUT] code: 'ETIMEDOUT', errno: 'ETIMEDOUT', syscall: 'connect' }, Does http-proxy have support for NodeJS4?