Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I know whether the connection to Cassandra was lost with the C++ driver?

I'm wondering whether there is a way for me to know whether the connection to all Cassandra nodes was lost by the C++ driver.

My application has a proxy server which connects to Cassandra once and sits there forever. Other services will connect to that proxy server and send requests as required.

That works great, until all the connections to the Cassandra cluster are lost. In that special circumstance, the proxy does not seem to recover...

Is there a way for me to know/detect that all connections were lost and thus attempt a connect() again?

like image 359
Alexis Wilke Avatar asked Dec 02 '25 01:12

Alexis Wilke


1 Answers

I have the same situation and the best solution is to check the error from the request/query you make to Cassandra. I just tested this and if all connections are gone, the driver immediately returns:

CASS_ERROR_LIB_NO_HOSTS_AVAILABLE

That's the solution I'm going myself with as I couldn't find a better one and actually this one works for me as it doesn't wait for a specific timeout but return immediately.

like image 177
Nikolay Dimitrov Avatar answered Dec 04 '25 14:12

Nikolay Dimitrov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!