【问题标题】:Node Redis throws read ETIMEDOUT error after some time节点 Redis 在一段时间后抛出读取 ETIMEDOUT 错误
【发布时间】:2023-02-07 17:01:55
【问题描述】:

几分钟不活动后,Node Redis 总是抛出 read ETIMEDOUT 错误并停止应用程序。

使用简单的expess.js 应用程序和 redis 客户端。

redis.createClient({
  url: "redis://default:user@123.123.12.123:6379"
});

【问题讨论】:

    标签: javascript node.js express redis


    【解决方案1】:

    经过多次尝试找出问题所在后,我找到了将pingInterval 选项添加到 Redis 配置的解决方案,因此连接始终处于活动状态。

    此配置解决了我的问题:

    redis.createClient({
      url: "redis://default:user@123.123.12.123:6379",
      pingInterval: 1000 // <- add pingInterval
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-08
      • 2017-04-03
      • 2015-03-26
      • 2019-08-07
      • 1970-01-01
      • 2023-04-03
      相关资源
      最近更新 更多