Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Node JS Redis Client Connection Retry

Node JS Redis Client Connection Retry


Currently I'm using as my Node Redis client.

client.retry_delay is set to 250ms default.

I tried the connecting to redis and once connection was successful, I manually stopped the Redis Server to see whether client.retry_delay works. But I didn't see it working.

The following log messages are logged on ready & end events on redisClients created using createClient

[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  '' '6379'
[2012-03-30 15:16:33.886] [FATAL] Development - Connection Terminated to  '' '6379'

I didn't see Success message again [ready event was not fired] when the server came back live

Am I missing something? When will be the retry constant used? Is there a work around to find whether a redis server has come up after a failure from node?

Problem courtesy of: Tamil


I can't reproduce this. Could you try this code, stop your redis server, and check the log output?

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);
Solution courtesy of: Linus Gustav Larsson Thiel


View additional discussion.

This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Node JS Redis Client Connection Retry


Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription