redis icon indicating copy to clipboard operation
redis copied to clipboard

Add ability to check if initial connection to server succeeded

Open ferchor2003 opened this issue 2 years ago • 2 comments

Some application will need to be able to check if initial connection to the server succeeded before sending any traffic to it. in other words, how can an app detect if the connection is up before trying to execute an exec() call?

ferchor2003 avatar Oct 23 '23 22:10 ferchor2003

The best way to check if a connection is up is by sending executing a command like PING with exec() command. In principle it is possible to check if the socket is open, but that is not as reliable. My recommendation however is for users to rely on the buil-in health-checker in Boost.Redis instead of trying to detect themselves. The health-checker is capable of establishing a new connection (to the same instance) when necessary.

Also, I recommend you having a look at redis::request::config to adjust the behaviour to your needs, the flag cancel_if_not_connected seems to be what you are looking for.

mzimbres avatar Nov 03 '23 20:11 mzimbres

Above I mean the flag boost::redis::request::config::cancel_if_not_connected.

Does that solve your problem? do your need any further help?

mzimbres avatar Nov 04 '23 10:11 mzimbres