node.js - 15 second delay on second request in node -


i have server need send multiple http requests. every request except first triggers ~15 second delay.

if send requests linux console, postman or fiddler works great, without delay, cannot work node.

i have tried https.get(), request, sockets , forking request in separate file. delay still there. server replies proper connection: close header. server nginx server.

the time works node if put request in separate script , runs script. works because node exits , releases connection after request.

i have tried agent: false , i'm sending connection: close server why take 15 seconds close, , why doesn't happen when using fiddler or postman?

edit: added code. code works first time run it, if run twice or more delay appears. it's second function causes delay, first function works fine.

async.waterfall([   function(cb) {     console.log('making first connection');     var post_data = querystring.stringify({                     'login' : username,                     'password'  : password                 });     var options = {                     hostname: 'hostname',                     port: 443,                     path: '/path',                     method: 'post',                     agent: agent,                     pool: false,                     keepalive: false,                     followredirect: false,                           headers: {                         'content-type': 'application/x-www-form-urlencoded',                         'content-length': post_data.length                     }                   };                           // headers including cookie                 var req = https.request(options, function(res) {                     console.log("statuscode: ", res.statuscode);                     cb(null, res.headers)                 });                  req.write(post_data);                 req.end();              },   function(header, cb) {     console.log('making second connection');         https.request({                     host: 'my.server',                     path: '/' + encodeuricomponent(params),                     port: 443,                     method: 'get',                     headers: {                         'cookie': 'iflang=eng;sessid=somesession',                         'connection': 'close',                         'content-length': 0                     }                 }, function(res) {                     console.log(res.headers);                 }).on('error', function(err){                     console.log(err);                 }).end();          },             ], function (err, result) {             if(err)                 console.error(err);             callback(err, result);         });  

update: code causes same delay, when running curl command command line can hammer server without delay.

var args = [   'https://myserver' + encodeuricomponent( urlpath ),   '-k',   '-v',   '-0',   '--no-keepalive',   '-b sessid=somesessionidfromfirstfunction', ];  child_process.spawn('curl', args); 


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -