You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
varhttp=require('http');varhttp_proxy=require('node-http-proxy');varrouter=http_proxy.createServer({router: {"/first":
"127.0.0.1:3000","/second": "127.0.0.1:3001"}});router.listen(80);http.createServer(function(req,res){res.writeHead(200,{'Content-Type': 'text/plain'});res.write("Hello From First");res.end();}).listen(3000);http.createServer(function(req,res){res.writeHead(200,{'Content-Type': 'text/plain'});res.write("Hello From Second");res.end();}).listen(3001);setTimeout(function(){router.close()},10000);setInterval(function(){console.log("hi")},3000);
So after 10 seconds, requesting /first should not resolve, yet it continues to resolve and respond with 'Hello From First' until you close the browser, then requests stop being routed. Confirmed in both Firefox 5 and Chrome.
The text was updated successfully, but these errors were encountered:
@nodesocket This is actually by design in node.js core and has nothing to do with node-http-proxy. Here's a quick sample repro'ing the problem with the http module:
varhttp=require('http');varclosed=false;varserver=http.createServer(function(req,res){if(!closed){closed=true;server.close();}console.log('Incoming connection');console.dir(server);res.writeHead(200,{'Content-Type': 'text/plain'});res.write("Hello From Server");res.end();})server.on('close',function(){console.log('server emitted close')});server.listen(3000);
It's actually good that the server does this because you want to keep serving all of your connections and not abruptly cut them off. What would be nice is if the close event didn't fire on the http.Server instance until all of the connections had closed gracefully. I've talked to @ry and opened an issue on node.js core: nodejs/node-v0.x-archive#1383
The following code reproduces the problem:
So after 10 seconds, requesting /first should not resolve, yet it continues to resolve and respond with 'Hello From First' until you close the browser, then requests stop being routed. Confirmed in both Firefox 5 and Chrome.
The text was updated successfully, but these errors were encountered: