redis / node-redis

Redis Node.js client

Home Page:https://redis.js.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a way to see if the client is connected?

spock123 opened this issue · comments

Not a bug per se, I'm trying to build in some backoff logic, in case Redis connection for some reason does not work. If the client loses connection, etc etc.

Is there a way I can check the instantiated client, or should I implement some logic myself using the client events?

The main issue for the latter is that the error event doesn't seem to give a good parseable error message - it's just a text, making it very difficult to parse. I can't figure out how to get a specific error code - only a descriptive text.

So my question is:
How would you check that the client is connected?

Thanks in advance

client.isOpen = the client is either connecting or reconnecting
client.isReady = the client is connected and ready for use

@leibale whoa that's amazing. So sorry for my stupidity.
I tried looking into the client value but couldn't find those values.

Closing and bowing out

More like not finished documentation... I'll leave this issue open as a documentation issue

I'll look at adding an example script for this into the examples folder.