目前我正在使用 https://github.com/mranney/node_redis作为我的 Node redis 客户端。
client.retry_delay
默认设置为 250 毫秒。
我尝试连接到 redis,连接成功后,我手动停止了 redis 服务器以查看 client.retry_delay
是否有效。但我没有看到它起作用。
以下日志消息记录在使用 createClient
创建的 redisClient 上的 ready
和 end
事件上:
[2012-03-30 15:13:05.498] [INFO] Development - Node Application is running on port 8090
[2012-03-30 15:13:08.507] [INFO] Development - Connection Successfully Established to '127.0.0.1' '6379'
[2012-03-30 15:16:33.886] [FATAL] Development - Connection Terminated to '127.0.0.1' '6379'
当服务器重新上线时,我没有再次看到成功消息 [ready event was not fired]。
我错过了什么吗?什么时候使用重试常量?是否有解决方法来查找在 Node 出现故障后是否出现了 Redis 服务器?
最佳答案
我无法重现这个。你能试试这个代码,停止你的 redis 服务器,然后检查日志输出吗?
var client = require('redis').createClient();
client.on('connect' , log('connect'));
client.on('ready' , log('ready'));
client.on('reconnecting', log('reconnecting'));
client.on('error' , log('error'));
client.on('end' , log('end'));
function log(type) {
return function() {
console.log(type, arguments);
}
}
关于node.js - Node JS Redis 客户端连接重试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9940873/