Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取大量图像的宽度会导致Node.js中出现eNotFind_Node.js_Http - Fatal编程技术网

获取大量图像的宽度会导致Node.js中出现eNotFind

获取大量图像的宽度会导致Node.js中出现eNotFind,node.js,http,Node.js,Http,我有几个图像列表源(闪烁、存储在s3的图像、imgur等) 我想得到这些图像的尺寸 我使用node和遍历每个url,并使用它来获得图像的宽度,并通过以下代码计算在某个宽度上有多少图像 probes = []; _.forEach(image_urls, url => { probes.push(probe(url)); }); results = await Promise.all(probes); _.forEach(results

我有几个图像列表源(闪烁、存储在s3的图像、imgur等)

我想得到这些图像的尺寸

我使用node和遍历每个url,并使用它来获得图像的宽度,并通过以下代码计算在某个宽度上有多少图像

    probes = [];

    _.forEach(image_urls, url => {
      probes.push(probe(url));
    });
    results = await Promise.all(probes);
     _.forEach(results, result_of_image => {
      width = parseInt(result_of_image.width / 10) * 10;
      if (!widthes[width]) {
       widthes[width] = 1;
      } else {
       widthes[width]++;
      }
     });
即使所有URL都是可访问的,我有时也会通过堆栈获得
getaddrinfo ENOTFOUND

at ClientRequest.req.once.err (/image_script/node_modules/got/index.js:73:21)
at Object.onceWrapper (events.js:293:19)
at emitOne (events.js:101:20)
at ClientRequest.emit (events.js:191:7)
at TLSSocket.socketErrorListener (_http_client.js:358:9)
at emitOne (events.js:96:13)
at TLSSocket.emit (events.js:191:7)
at connectErrorNT (net.js:1031:8)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)
我怀疑,由于url列表非常大(以千计),该节点占用了系统的所有资源,因此无法正常工作(这是一个猜测)

有没有更好的方法来实现上述目标?或者为节点提供一些连接池