【问题标题】:how to solve error read ECONNRESET bull library如何解决错误读取 ECONNRESET 公牛库
【发布时间】:2021-10-26 16:09:44
【问题描述】:

当我在节点 js 中使用bull 库排队时出现错误,错误是这样的:

     Error: read ECONNRESET at TCP.onStreamRead 
    - - errno: -104,
   - - code: 'ECONNRESET',
   - - syscall: 'read'
   - - }

 MaxRetriesPerRequestError: Reached the max retries per request limit (which is 20). Refer to "maxRetriesPerRequest" option for details.

这是我的代码:

const imageQueue = new Bull("imageQueue", process.env.REDIS_URL);

【问题讨论】:

    标签: node.js heroku redis queue bull


    【解决方案1】:

    通过添加 tls 成功解决错误

    const imageQueue = new Bull("imageQueue", process.env.REDIS_TLS_URL, {
      redis: { tls: { rejectUnauthorized: false } },
    });
    

    【讨论】:

      【解决方案2】:

      bull 使用 ioredis 进行连接,并在 Queue 构造函数中允许第三个 opts 参数。根据source code it looks for a redis property within those opts.

      你可以试试这个raise the retry limit to 100

      const opts = {redis:{maxRetriesPerRequest:100}}
      const imageQueue = new Bull("imageQueue", process.env.REDIS_URL, opts);
      

      但是,同样,您使用 Heroku 的 redis 服务的频率可能超过了免费层所允许的范围(如果您使用的是这样的话)。

      【讨论】:

      • 感谢您的回答,目前仍有ECONNRESET错误。为了您在我的本地计算机上的信息,它可以工作,只有在连接 redis heroku 时才会出错。
      • 啊哈,在这种情况下,您可能超出了 Heroku 的 redis 服务限制。我认为他们按小时收费,因此您可以提供更昂贵的计划,看看它是否更适合您。这将检验我超出其极限的假设。
      • 我的套餐有Premium 0,还缺吗?
      猜你喜欢
      • 2013-11-17
      • 1970-01-01
      • 2021-01-25
      • 2018-06-13
      • 1970-01-01
      • 2018-03-21
      • 2020-11-16
      • 1970-01-01
      • 2019-06-21
      相关资源
      最近更新 更多