openresty / lua-resty-redis

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

Update question: Need latest release to support SSL #175

Open leovic0101 opened 5 years ago

leovic0101 commented 5 years ago

This is really more of a question than an issue.

We need to use the latest update with SSL support. It works and thank you for releasing it. However, the only way I know right now to update the module is to overwrite the redis.lua.

I tried using yum to update openresty as well as using luarocks but neither works.

I am noob but would like to know what is your recommendation to update to the latest version?

Thank you and most appreciate it.

akuma12 commented 5 years ago

I'm in the same boat. I have the redis.lua file overwritten in my repo, but it would be great if I didn't have to do that.

zffocussss commented 4 years ago

me too

zffocussss commented 4 years ago

Hi @leovic0101: I can not redis after overwrite redis.lua with the latest file,it failed.Can you help me? redis failed to authenticate: timeout

leovic0101 commented 4 years ago

@zffocussss not sure what your configuration is but if you are running in SSL you will need to add the options parameter. In my case, I set it up something like this:

    local resty_redis = require "resty.redis"
    local redis = resty_redis:new()             

    -- Syntax: redis:set_timeouts(connect_timeout, send_timeout, read_timeout) 
    redis:set_timeouts(5000, 5000, 5000) -- 5 sec

       local ok, err = redis:connect("**<<Redis IP>>**", **<<Redis SSL Port>>**, {
                            ssl = true,
                            ssl_verify = true,
                            pool_size = 100,
                            backlog = 300
                    })
    if not ok then
        ngx.say("Failed to connect: ", err)
        return ngx.exit(500)
    end             

    local response, err = redis:auth('**<<Redis AUTH password>>**')
    if not response then
        ngx.say("Failed to authenticate: ", err)
        return ngx.exit(500)
    end
zffocussss commented 4 years ago

@leovic0101 what if I do not set pool_size and backlog?

zffocussss commented 4 years ago

it failed redis failed to authenticate: timeout

zffocussss commented 4 years ago

lua tcp socket read timed out redis failed to authenticate: timeout

zffocussss commented 4 years ago

version: nginx version: openresty/1.13.6.2

zffocussss commented 4 years ago

overwrite the redis.lua

how do you overwrite the redis.lua?

jloh commented 4 years ago

@zffocussss edit the file located here /usr/local/openresty/lualib/resty/redis.lua (on Ubuntu at least).

Would be amazing to get a new version of this out so that it can work easily with SSL enforced situations! Let me know if there is anything I can do to help.

leovic0101 commented 4 years ago

thanks @jloh

Also make sure that the updated redis.lua has the proper permission. Run command below:

chmod +r /usr/local/openresty/lualib/resty/redis.lua

Sorry for the late response.