Open hisaha opened 6 years ago
I am investigating this issue. I have omitted the pthread part, this issue could be reproduced simply. Clinent2 is disconnected from localhost:6380, the ping process of client1 is also stopped. I think it is spec of io_service at tacopie... Any hints?
The sample code is below.
#include <unistd.h>
#include <cpp_redis/cpp_redis>
cpp_redis::client client1;
cpp_redis::client client2;
void redisChangeStateHanlder(const std::string& host, std::size_t port, cpp_redis::client::connect_state status)
{
if(port==6379)
std::cerr << "client1 ";
if(port==6380)
std::cerr << "client2 ";
if (status == cpp_redis::client::connect_state::dropped) {
std::cerr << "connection dropped from " << host << ":" << port << std::endl;
}
}
int main()
{
cpp_redis::client::connect_callback_t f = redisChangeStateHanlder;
client1.connect("localhost", 6379, f, 3000, -1, 3000);
client2.connect("localhost", 6380, f, 3000, -1, 3000);
while(true)
{
if(client1.is_connected())
{
client1.ping([](cpp_redis::reply& reply) {
std::cerr << "ping1: " << reply << std::endl;
});
client1.commit();
}
if(client2.is_connected())
{
client2.ping([](cpp_redis::reply& reply) {
std::cerr << "ping2: " << reply << std::endl;
});
client2.commit();
}
sleep(1);
}
return 0;
}
Hi,
I create two client to connect two redis server with pthread. If a instance disconnected with server problem, another instance also blocked. I think it is strange result, I expect another instance keep to work.
The test code is below.
I expect the client1 keep to ping to 6379, but the bot client1/2 is stopped. The output log is below
As you see, the client1 failed to ping... But the redis-server of 6379 for client1 is alive. Is this bug or specification of cpp_redis?
Additionally, I used below cmake for build, and my environment is OSX(High sierra). The redis-server is installed with homebrew.