mardi 2 juillet 2019

cpp_redis::subscriber -> connect caused exception: connect() failure

When I call "connect" to a Redis publisher, client gets exception "connect() failure" for some of my client/server combinations. Other clients/servers run smoothly.

I am running Redis version 3.2.100 on windows (this is the newest windows Redis server available). Using cpp_redis as client. VisualStudio 2015 is my environment.

cpp_redis::redis_subscriber *subscriber = new cpp_redis::redis_subscriber();
std::string hostIP = 12.0.0.1; // Redis server IP address
int port = 6379;
std::string password = "my_password";
bool isConnected = false;
try
{
    subscriber->connect(hostIP, port, nullptr);
    if (password != "")
    {
        subscriber->auth(password, [this](const cpp_redis::reply& reply)
      {
        if (!reply.is_error()
            {
            isConnected = true;
        }
      }
     );
    }
}
catch (const std::exception& exs)
{
   std::cout << exs.what()) << std::endl;
}

How comes that same code results for some client/server systems, I get proper connection and subscription works - and for other systems, I get exception on command

-- subscriber->connect(... etc. ?

the exception text is connect() failure

Any insights? thank you!

Aucun commentaire:

Enregistrer un commentaire