-
Notifications
You must be signed in to change notification settings - Fork 452
error connection to redis unix socket #187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
when i use network config is true, use socket is false |
@davidka79 are you sure there is no other mistakes like a typo in your code? |
The second argument of `sock:connect()` cannot be `nil`. Fixes openresty#187 Bug introduced by 79d2421
@doujiang24 Unfortunately, 79d2421 introduced a bug, which broke The connect method of a TCP socket |
unix socket connection problem continues .. @bjoe2k4 |
Have you tried my fix from the pull request? Waiting for my pull to be merged may take a while. Unfortunately openresty devs are super busy these days and development (at least the public opensource part) is sometimes stalled for weeks, months and years. Nevertheless the openresty platform is one of the most stable platforms i have ever encountered and i am more than grateful to what i have learned by using it. Also there is openresty/lua-nginx-module#1735 going on, which will likely require some changes on my side. |
Uh oh!
There was an error while loading. Please reload this page.
Hello
I would like to use only unix socket for redis connect, but when I try to do simple connection as in examples, I getting error:
2020/03/09 09:59:57 [error] 1878#1878: *18 lua entry thread aborted: runtime error: /opt/nginx/lualib/resty/redis.lua:141: bad argument #2 to 'connect' (number expected, got nil)
stack traceback:
coroutine 0:
[C]: in function 'connect'
/opt/nginx/lualib/resty/redis.lua:141: in function 'connect'
/opt/nginx/lualib/init.lua:29: in function </opt/pop/lualib/init.lua:23>, context: ngx.timer, client: 185.40.72.110, server: 0.0.0.0:443
2020/03/09 09:59:57 [error] 1878#1878: *19 lua entry thread aborted: runtime error: /opt/nginx/lualib/resty/redis.lua:141: bad argument #2 to 'connect' (number expected, got nil)
and my code is
in init_by_lua
--# LOGGING FUNCTION
function putLog(premature, customer)
-- redis connect
local redis = require "resty.redis"
local red = redis:new()
red:set_timeouts(1000, 1000, 1000)
local ok, err = red:connect("unix:/var/run/redis/redis.sock")
-- DB INSERT
red:select(0)
red:hincrby(customer, 'count', 1)
-- end, release connection back to pool
local ok, err = red:set_keepalive(10000, 100)
if not ok then
ngx.log(NGX.ERR, "failed to set keepalive: ", err)
return
end
end
log_by_lua_block {
local customer = tonumber(ngx.var.customer) or 0
local ok, err = ngx.timer.at(1, putLog, customer)
if not ok then
ngx.log(ngx.ERR, "ERROR from the CODE: failed to create timer: ", err)
end
}
OS:
Ubuntu Server 18.04.4
redis socket location:
/var/run/redis/redis.sock
srwxrw-rw- 1 redis redis 0 Feb 29 18:54 redis.sock
redis-cli and goland apps can connect to socket, I mean socket is present
Thank you
ADD:
If I use IP:Port instead of socket, everything is fine
UPD:
It does not mater socket is present or not, I getting this error even if I put wrong path to connection string :(
The text was updated successfully, but these errors were encountered: