doujiang24 / lua-resty-kafka

Lua kafka client driver for the Openresty based on the cosocket API
BSD 3-Clause "New" or "Revised" License
802 stars 275 forks source link

no resolver defined to resolve #28

Closed noahyao1024 closed 8 years ago

noahyao1024 commented 8 years ago

Nginx.conf ngx.say("[start lua kafka]") local cjson = require "cjson" local client = require "resty.kafka.client" local producer = require "resty.kafka.producer" local broker_list = { { host = "127.0.0.1", port = 9094}, } local topic = "hellokafka"; local cli = client:new(broker_list) local brokers, partitions = cli:fetch_metadata(topic)

ngx.say("[fetch_metadata]");
if not brokers then
    ngx.say("fetch_metadata failed, err: ", partitions)

end
ngx.say("brokers: ", cjson.encode(brokers), ";\npartitions: ", cjson.encode(partitions), ";")
ngx.say("[send message]");

local key = nil
local message = "hello nginx kafka lua"
local bp = producer:new(broker_list)
local ok, err = bp:send(topic, nil, message)
if not ok then
    ngx.say("send err:", err)
return
end
ngx.say("send success, ok:", ok)

Output: [start lua kafka] [fetch_metadata] brokers: [null,{"host":"cp01-rdqa-dev340.cp01.baidu.com","port":9094}]; partitions: {"errcode":0,"num":1,"0":{"id":0,"errcode":0,"replicas":[2],"isr":[2],"leader":2}}; [send message] send err:no resolver defined to resolve "cp01-rdqa-dev340.cp01.baidu.com"

Can't resolve the Hostname? Please Help me...

noahyao1024 commented 8 years ago

I have solve this by watching other ISSUE! Thank you for your fantanstic extension!

gemelen commented 8 years ago

Note for this issue: nginx directive "resolver" should be added to the level from which this code is executed (be it http or location).

doujiang24 commented 8 years ago

considered solved :)