title: How do you kill a redis client when there is no connection?
body: <p>I have a valid server configuration in which redis can't be accessed, but the server can function correctly (I simply strip away features when redis can't be found).</p>
  
  <p>However, I can't manage the connection errors well. I'd like to know when a connection error fails and shutdown the client in that case. </p>
  
  <p>I've found that the connection retry will never stop. And quit() is actually swallowed - "Queueing quit for next server connection." - when called. </p>
  
  <p>Is there a way to kill the client in the case where no connection can be established?</p>
  
  <pre><code>var redis = require("redis"),
      client = redis.createClient();
  
  client.on("error", function(err) {
      logme.error("Bonk. The worker framework cannot connect to redis, which might be ok on a dev server!");
      logme.error("Resque error : "+err);
      client.quit();
  });
  
  client.on("idle", function(err) {
      logme.error("Redis queue is idle. Shutting down...");
  });
  
  client.on("end", function(err) {
      logme.error("Redis is shutting down. This might be ok if you chose not to run it in your dev environment");
  });
  
  client.on("ready", function(err) {
      logme.info("Redis up! Now connecting the worker queue client...");
  });
  </code></pre>
  
  <ul>
  <li>ERROR - Resque error : Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED</li>
  <li>ERROR - Redis is shutting down. This might be ok if you chose not to run it in your dev environment</li>
  <li>ERROR - Resque error : Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED</li>
  <li>ERROR - Resque error : Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED</li>
  <li>ERROR - Resque error : Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED</li>
  <li>ERROR - Resque error : Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED</li>
  </ul>
  
  <p>One thing that is interesting is the fact that the 'end' event gets emitted. Why?</p>