microsoft / hiredis

Minimalistic C client for Redis >= 1.2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pub/sub issue with remote redis-server

zapredelom opened this issue · comments

redis subscribe does not working after several minutes of getting messages if redis publisher in remote host. When the publisher and subscriber are in same host , pub/sub works OK. but when programm subscribes to remote host after couple of minutes the messages published from remote redis host does not reach's to local client.
here is simple code which reproduces issue

    aeEventLoop* loop_ = aeCreateEventLoop(1024 * 10);
    redisAsyncContext* redisContext_ = redisAsyncConnect(<remote-host>,<remote-port);
    if (redisContext_ == NULL || redisContext_->err)
    {
        // TODO: handle error
    }
    redisAsyncSetDisconnectCallback(redisContext_, [](const struct redisAsyncContext*, int status){std::cout << "disconnected :(" << std::endl; });
    redisAeAttach(loop_, redisContext_);
    int ret = redisAsyncCommand(redisContext_, PubSubCallbackHelper, NULL, "subscribe foo");
    aeMain(loop_);