ledgetech / lua-resty-redis-connector

Connection utilities for lua-resty-redis
234 stars 71 forks source link

nginx: [error] init_by_lua_file error: /tmp/a/resty/redis/connector.lua:70: no request object found for sentinel connection #10

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hi @pintsized I'm getting "no request object found" error on sentinel connection. can you please help me on this error.

nginx: [error] init_by_lua_file error: /tmp/a/resty/redis/connector.lua:70: no request object found stack traceback: [C]: in function 'ngx_re_match' /tmp/a/resty/redis/connector.lua:70: in function 'parse_dsn' /tmp/a/resty/redis/connector.lua:104: in function 'connect' /opt/nginx/conf/script/push_data.lua:30: in main chunk nginx: configuration file /opt/nginx//conf/nginx.conf test failed

connection string as below

local redis, err = rc:connect{ url = "sentinel://mymaster:a", sentinel = { host = "127.0.0.1", port = "26379" } }

pintsized commented 7 years ago

Have you read the documentation on using cosockets in the init phases?https://github.com/openresty/lua-nginx-module#cosockets-not-available-everywhere

pintsized commented 7 years ago

In short, if you really do intend to connect to Redis when Nginx starts, use the ngx.timer API to create a "light thread" in your init phase, as this light thread will be able use cosockets.