i have nodejs http server. after sending 1 request , getting response i'm trying close using server.close() takes long time close (more 60s). can problem?
edit
currently i'm using chromes advanced rest client testing, sending 1 request results slow closing after getting response, far know should not stuck keep-alive. i'm defiantly closing response response.end() after response.write().
here code:
handlerequest = function (request, response) { var body = ''; request.on('data', function (data) { body += data; }); request.on('end', function () { // data db... response.setheader('content-type', 'application/json'); response.write(result); response.end(); } var server = http.createserver(handlerequest); server.listen(8000); process.on('sigint', function(){ if (server != undefined) { console.log("closing server..."); server.close(function (e) { if (e) { throw 'error on closing server'; } else { console.log("server closed"); } }); } });
please check have close response, after sending data.
response.end()
if doesn't work can post code sample.
Comments
Post a Comment