api7 / lua-resty-etcd

Nonblocking Lua etcd driver library for OpenResty
https://api7.ai/
Apache License 2.0
191 stars 54 forks source link

attempt to call method 'watch' (a nil value) #53

Open wuchencm opened 4 years ago

wuchencm commented 4 years ago

attempt to call method 'watch' (a nil value)

wuchencm commented 4 years ago

attempt to call method 'watch' (a nil value) attempt to call method 'watchdir' (a nil value) the same to watchdir

membphis commented 4 years ago

please take a look at this test case, confirm you are using with right way:

https://github.com/iresty/lua-resty-etcd/blob/5e3037f94d3fd350e7d6ce1d29f93d93edc6d522/t/v3/key.t#L125

if you still have a problem, please provide your mini case.

wuchencm commented 4 years ago

please take a look at this test case, confirm you are using with right way:

https://github.com/iresty/lua-resty-etcd/blob/5e3037f94d3fd350e7d6ce1d29f93d93edc6d522/t/v3/key.t#L125

if you still have a problem, please provide your mini case.

image

wuchencm commented 4 years ago

please take a look at this test case, confirm you are using with right way: https://github.com/iresty/lua-resty-etcd/blob/5e3037f94d3fd350e7d6ce1d29f93d93edc6d522/t/v3/key.t#L125

if you still have a problem, please provide your mini case.

image

`local etcd, err = require("resty.etcd").new({protocol = "v3"}) local body_chunk_fun, err = etcd:watch("/4c",{timeout = 0.5})

if not body_chunk_fun then ngx.say("failed to watch: ", err) end

local idx = 0 while true do local chunk, err = body_chunk_fun() if not chunk then if err then ngx.say(err) end break end idx = idx + 1 ngx.say(idx, ": ", require("cjson").encode(chunk.result)) end

`

The log: 2020/02/21 22:20:53 [info] 1565#1565: *1127 [lua] v3.lua:502: request_chunk(): http request method: POST path: /v3beta/watch body: {"create_request":{"key":"LzRj"}} query: nil, client: 192.168.0.105, server: localhost, request: "GET /gray HTTP/1.1", host: "192.168.0.107" 2020/02/21 22:20:54 [error] 1565#1565: *1127 lua tcp socket read timed out, client: 192.168.0.105, server: localhost, request: "GET /gray HTTP/1.1", host: "192.168.0.107"

web 1: {"created":true,"header":{"raft_term":"4","cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"18"}} timeout

membphis commented 4 years ago

the error log is info level, we can ignore it.

if you use watch API, you need to confirm your data in etcd is a JSON value.

please take a mini case like this one: https://github.com/iresty/lua-resty-etcd/blob/5e3037f94d3fd350e7d6ce1d29f93d93edc6d522/t/v3/key.t#L125

We do not know what is the value in your etcd. If you need help, please provide an example that can reproduce the problem.