简体   繁体   中英

How to make multiple http call requests (Nodejs )

Need server script for calling many url's synchronously . I tried on nodejs . but wordpress wp-cron.php url gives 500 error's 6 out of 10

var http = require('http');
var request = require('request');
var conn=[];
for(var i=0;i<100;i++){
conn[i]=request('http://www.example.com/site/wp-cron.php', function (error, response, body) {


if (!error && response.statusCode == 200) {
      }
     console.log(response.statusCode);
    });
   }

Any suggestion to achieve my objective ?

Maybe the site has a mechanism of avoiding the span request, so you should controle your request.

Here is a tutorial in my github project of controlling concurrent request, using a tool called "async" : asyncControle

If you have any questions, please contact me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM