Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redis with haproxy #46

Open
aidevr opened this issue Sep 30, 2016 · 3 comments
Open

redis with haproxy #46

aidevr opened this issue Sep 30, 2016 · 3 comments

Comments

@aidevr
Copy link

aidevr commented Sep 30, 2016

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.

@luca3m
Copy link
Owner

luca3m commented Sep 30, 2016

Are you using this class? It automatically recycles connection.

@aidevr
Copy link
Author

aidevr commented Sep 30, 2016

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......

@luca3m
Copy link
Owner

luca3m commented Nov 2, 2016

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants