nrk/redis-lua

Why client lost in Redis server?

coanor opened this issue · 1 comments

I use redis_connect(ip, port) to connect the Redis server(long time connection), then it works well, but about 10 minutes later,the connection is closed(active or passive, I don't know)

false : lua_scripts/lib/redis.lua:264: connection error: closed

And all the successive command are failed. I have browsed the out put of CLIENT LIST, and not list my client's IP, why this happened?

nrk commented

Hi @coanor,

First of all you should make sure that the timeout value is set to 0 on your Redis server (see redis.conf) or it will drop any client idling for more than the specified value (not-so-old versions of Redis had a default timeout of 300 seconds AFAIR, now the default is 0).

On the client end you must create the connection by setting the timeout parameter to 0 like in the following snippet to prevent the socket from being closed for a timeout when there's no activity:

local redis = require 'redis'
local client = redis.connect({ host = '127.0.0.1', timeout = 0 })