redis3m icon indicating copy to clipboard operation
redis3m copied to clipboard

redis with haproxy

Open aidevr opened this issue 9 years ago • 3 comments

I'm using redis using haproxy and not managing connections with sentinels. Sentinels is being used for automatic fail-over, when fail-over happens redis3m returns transport_failur which I have put in try catch and haved continued once the exception is caught. But my connection object gets invalid and no other command is running on that object whereas connection with haproxy remains intact. What i want is to refresh redisContext of my connection such that my connection with haproxy does not break and redisContext gets refreshed. I have used redisFreeKeepFd and redisConnectFd but I'm unable to set new context to current connection object.

aidevr avatar Sep 30 '16 07:09 aidevr

Are you using this class? It automatically recycles connection.

luca3m avatar Sep 30 '16 09:09 luca3m

Im using connection class here is the sample code

connection::ptr_t conn = connection::create("127.0.0.1",port);
    unsigned int i = 0;
    while(i <numMessage) {
        if(conn->is_valid())
        {
            cout << " valid" << endl;
        }
      i++;
    string index = boost::lexical_cast<string>(i);
    string key = "mystore"+ index;
    string message = "Test message";
   cout << "in here" << endl;
    command t = command("SET") << key << message;
    try {
    conn->run(t);
    } catch(std::exception &ex) {
     sleep(2);
     continue;
    }

all iteration goes into the exception......

aidevr avatar Sep 30 '16 09:09 aidevr

I got your point, unfortunately redis3m has not been built for this scenario. But if you manage to find a solution a pull request is very welcome!

luca3m avatar Nov 02 '16 15:11 luca3m