Open abbas-gadhia opened 7 years ago
Can't reproduce, are you sure that it is an issue with either http-proxy or cors-anywhere, and not with your own application or set-up?
I followed the following steps to test this, with Node.js v8.1.3:
npm install
to install the dependencies.node server.js
to start CORS Anywhere with default settings.Start a server that accepts a connection but does not respond to requests, e.g.:
require('http').createServer(function(req, res) {
console.log(req.url, req.headers);
req.once('close', () => { console.log('end of request'); });
}).listen(9000, '127.0.0.1');
curl -H 'Origin: null' http://localhost:8080/http://localhost:9000/test -vvv --max-time 300
Result from step 3:
'/test' { origin: 'null',
accept: '*/*',
'user-agent': 'curl/7.54.1',
host: 'localhost:9000',
connection: 'close' }
end of request
Result from step 4:
* Trying ::1...
* TCP_NODELAY set
* connect to ::1 port 8080 failed: Connection refused
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /http://localhost:9000/test HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.54.1
> Accept: */*
> Origin: null
>
< HTTP/1.1 404 Not Found
< Access-Control-Allow-Origin: *
< Date: Thu, 13 Jul 2017 21:12:13 GMT
< Connection: keep-alive
< Transfer-Encoding: chunked
<
* Connection #0 to host localhost left intact
Not found because of proxy error: Error: socket hang up
I'm using Cors-Anywhere (https://github.com/Rob--W/cors-anywhere) for proxying my request (which uses node-http-proxy)
After 2 minutes (120 seconds), the request gets retried if there is no response from the server. This behavior was counter-productive for my problem, since if a request is taking long, i dont want to further burden the server with a similar request.
After setting the value for
proxyTimeout
parameter, this behavior stops.I dont see this behavior documented anywhere on this project? Should i do so or have i analyzed the problem incorrectly?