Hello, it seems server can not close immediately after setTimeout(5 sec). Maybe server is waiting for HTTP pipeline close and it can close after HTTP close
在 2015年8月13日星期四 UTC+8上午3:39:40,Kiran Ravuri写道: > > Hi All, > > I am testing cluster in node, and i had a question regarding that which i > posted > > @ > http://stackoverflow.com/questions/31934358/nodejs-worker-disconnect-not-working-as-expected > > > This is the followup question to that, cos i found the similar behavior in > this test . > > *SERVER :* > > var http=require("http"), > server = null; > > server =http.createServer(function (request, response) { > request.on("end", function(){ > console.log("reqest end " + new Date()); > }); > request.on("data", function(data) { > console.log("I am here"); > console.log(data.toString("utf8")); > }); > response.writeHead(200, {'Content-Type': 'text/plain'}); > response.end('Hello World\n'); > }).listen(3000); > > server.on('request', function(sock) { > console.log('Got Request ' + new Date()); > }); > > setTimeout(function(){ > console.log('SERVER: calling server.close ' + new Date() ); > server.close(function() { > console.log('SERVER: has closed ' + new Date() ) > }); > }, 5000); > > *LOG:* > > > node app/http_server_test.js > Got Request Wed Aug 12 2015 20:09:21 GMT+0530 (IST) > reqest end Wed Aug 12 2015 20:09:21 GMT+0530 (IST) > SERVER: calling server.close Wed Aug 12 2015 20:09:23 GMT+0530 (IST) > SERVER: has closed Wed Aug 12 2015 20:11:17 GMT+0530 (IST) > > My question is why the server is taking that much time( about 2 mins) to > close even though there are no pending requests in the queue?? > > Thanks in advance. > > BRs > Kiran > > > -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/ed368b73-b836-4833-800a-45c28fa479e7%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
