I have nodejs http server. After sending one request and getting the response back I'm trying to close it using server.close() but it takes a very long time to close (more than 60s). What can be the problem?
Edit
Currently I'm using chromes advanced rest client for testing, sending one request results with the slow closing after getting the response, as far as I know it should not stuck with keep-alive. I'm definitely closing my response with response.end() after response.write().
Here is some code:
handleRequest = function(request, response) {
var body = '';
request.on('data', function (data) {
body += data;
});
request.on('end', function() {
// get some data from 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");
}
});
}
});