redis回调在失败后没有触发

时间:2014-01-28 07:29:13

标签: node.js redis

我正在使用的示例代码:

var conf = require('../Config'),
    redisConf = conf.get('redis'),
    redis = require('redis'),
    redisClient = redis.createClient(redisConf.port, redisConf.host),
    redisSub = redis.createClient(redisConf.port, redisConf.host);

redisSub.subscribe('test');

redisSub.on('message', function(channel, data) {
   console.log('got message on channel: ' + channel + ' with message: ' + data);
   redisClient.get ....
});

redisSub.on('error', function (err) {
    console.log("redisSub error: " + err);
});

redisSub.on('ready', function () {
   console.log('redisSub subscriber ready');
});

redisSub.on('reconnecting', function () {
   console.log('redisSub subscriber reconnecting');
});

redisSub.on('end', function () {
   console.log('redisSub subscriber ended');
});

redisClient.on('error', function (err) {
    console.log("redisClient error: " + err);
});

redisClient.on('ready', function () {
   console.log('redisClient ready');
});

redisClient.on('reconnecting', function () {
   console.log('redisClient reconnecting');
});

redisClient.on('end', function () {
   console.log('redisClient ended');
});

我启动了nodejs服务器,一切都按预期工作。 当我重新启动redis服务器时,没有调用任何回调,并且我没有在通道上收到任何消息,并且在我重新启动nodejs服务器之后,redis客户端正常连接并且一切都恢复正常。

0 个答案:

没有答案