有人可以解释ENOBUFS错误吗? [英] Can someone explain an ENOBUFS error?

查看:88
本文介绍了有人可以解释ENOBUFS错误吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在对Windows 7 64位OS上包含大量数据的数据库进行大量调用.由于呼叫正在排队,因此我得到了错误(在出现第一个错误之后,将永远进行HTTP调用):

I'm making a bunch calls to a database that contains a large amount of data on a Windows 7 64 bit OS. As the calls are queuing up I get the error (for ever HTTP call after the first error):

Error: connect ENOBUFS *omitted* - Local (undefined:undefined)

从我的google搜索中,我了解到此错误意味着我的缓冲区变得太大,并且系统的内存无法再处理该缓冲区的大小.

From my google searching I've learned that this error means that my buffer has grown too large and my system's memory can no longer handle the buffer's size.

但是我真的不明白这意味着什么.我正在将node.js与HTTPS库一起使用来处理我的请求.当请求进入队列并且套接字打开时,缓冲区的大小是否分配在RAM中?什么将使缓冲区扩展到更大的大小?这仅仅是硬件限制吗?

But I don't really understand what this means. I'm using node.js to with an HTTPS library to handle my requests. When the requests are getting queued and the sockets are opening is the buffer's size allocated in RAM? What will allow the buffer to expand to a greater size? Is this simply a hardware limitation?

我还阅读到某些操作系统比其他操作系统能够更好地处理缓冲区的大小.是这样吗如果是这样,哪种操作系统更适合运行需要通过HTTPS请求获取大量数据的节点脚本?

I've also read that some OS are able to handle the size of the buffer better than other OS's. Is this the case? If so which OS would be better suited for running a node script that needs to fetch a lot of data via HTTPS requests?

这就是我处理请求的方式.

Here's how I'm doing my requests.

for (let j = 0; j < dataQueries; j++) {
 getData(function())
}

function getData(callback){
 axios.get(url, config)
   .then((res) => {
      // parse res 
      callback(parsedRes(res))
   }).catch(function(err) {
      console.log("Spooky problem alert! : " + err);
   })
}

为了简洁起见,我省略了一些代码,但这通常是我处理请求的方式.我有一个for循环,每次迭代都会通过axios启动GET请求.

I've omitted some code for brevity, but this is generally how I'm doing my requests. I have a for loop that for every iteration launches a GET request via axios.

我知道有一个axios.all命令用于存储axios.HTTPMethod给您的诺言,但是当我将其设置为存储诺言然后通过axios遍历诺言时,代码没有变化.all

I know there is an axios.all command that is used for storing the promise the axios.HTTPMethod gives you, but I saw no change in my code when I set it up to store promises and then iterate over the promises via axios.all

推荐答案

感谢@Jonasw的帮助,但是有一个非常简单的解决此问题的方法.我使用了小型图书馆节流队列来完成工作.(如果您查看源代码,则基于此程序包实现自己的队列将非常容易.

Thanks @Jonasw for your help, but there is a very simple solution to this problem. I used the small library throttled-queue to get the job done. (If you look at the source code it would be pretty easy to implement your own queue based on this package.

我的代码更改为:

const throttledQueue = require('throttled-queue')

let throttle = throttledQueue(15, 1000) // 15 times per second

for (let j = 0; j < dataQueries; j++) {\
 throttle(function(){
   getData(function(res){
     // do parsing
   })
 }

}

function getData(callback){
 axios.get(url, config)
   .then((res) => {
      // parse res 
      callback(parsedRes(res))
   }).catch(function(err) {
      console.log("Spooky problem alert! : " + err);
   })
}

这篇关于有人可以解释ENOBUFS错误吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆