openresty / lua-resty-redis

Lua redis client driver for the ngx_lua based on the cosocket API
1.91k stars 448 forks source link

Reading from client: error:0A000126:SSL routines::unexpected eof while reading #276

Open cen1 opened 6 months ago

cen1 commented 6 months ago

Redis server logs the line from the title after each request. It is a debug log level and everything seems to work fine but I think there might still be some problem with SSL handling.

Using docker: openresty/openresty:1.25.3.1-2-bookworm-fat redis:7.2.5-bookworm

Redis started with: redis-server --loglevel debug --tls-port 6379 --port 0 --tls-auth-clients no --tls-cert-file /tls/server.crt --tls-key-file /tls/server.key --tls-ca-cert-file /tls/ca.crt --requirepass 123456

LUA code:

local redis_options = {
    ssl = true,
    ssl_verify = true
}
local redis_host = os.getenv("REDIS_HOST")
local redis_port = os.getenv("REDIS_PORT")

local redis = require "resty.redis"
local red = redis:new()
local ok, err = red:connect(redis_host, redis_port, redis_options)
if not ok then
    ngx.log(ngx.ERR, "Failed to connect to Redis: ", err)
    ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR)
end

-- Redis AUTH
local redis_password = os.getenv("REDIS_PASSWORD")
local res, err = red:auth(redis_password)
if not res then
    ngx.log("failed to authenticate with redis AUTH: ", err)
    ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR)
end

-- do some read/writes here...