redis连接每隔2个小时报错ECONNRESET
使用redis模块
const Promise = require("bluebird");
const redis = require("redis");
Promise.promisifyAll(redis.RedisClient.prototype);
Promise.promisifyAll(redis.Multi.prototype);
var RedisClient = redis.createClient("192.168.59.101", 6379);
RedisClient.on("connect", () => {
logger.info("connect to redis success");
});
RedisClient.on("error", err => {
console.error(err);
});
ECONNRESET每隔2个小时发生一次:
{
"syscall": "read",
"code": "ECONNRESET",
"errno": "ECONNRESET"
}
这个问题似乎和TCP keepalive有关,因为tcp_keepalive_time是7200秒,刚好是2个小时。。
cat /proc/sys/net/ipv4/tcp_keepalive_time
7200
Github上看到有遇到类似情况的,但是木有解决方案,大家知道这是什么原因么