doujiang24 / lua-resty-kafka

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

no resolver defined to resolve "name" #5

Closed esha- closed 8 years ago

esha- commented 9 years ago

Hello! May be you can help me. I have some producer:

 local broker_list = {
    { host = "127.0.0.1", port = 9092 }
 }
local p = producer:new(broker_list)
local key = "key"
local mess = "hi"
local offset, err = p:send('test', key, mess)

I get responce: no resolver defined to resolve "esha" I searched about nginx resolver, but not solve my problem. In my /etc/resolv.conf: nameserver 127.0.1.1 In my /etc/hosts:

127.0.0.1   localhost
::1         localhost
27.0.1.1   esha

Where "esha" in error? If i have "localhost" in broker list ?

Now, i solve problem use "stub" in /producer.lua:

129     local config = brokers[leader]
130     
131     config.host = "127.0.0.1"
132     local bk = broker:new(config.host, config.port, self.socket_config)
133     self.producer_brokers[leader] = bk
134     
135     return bk

What would you recommend?

doujiang24 commented 9 years ago

first, we request for the metadata through the kafka metadata api, and kafka return the host "esha", this is ok but nginx can not resolver "esha" that because nginx can only resolver a name from dns server ( yeah, even can not resolver from /etc/hosts)

the simple way is config host.name in config/server.properties to kafka server, may be:

host.name=127.0.0.1

this means we direct use ip instead http://kafka.apache.org/documentation.html#brokerconfigs

another may is to build a dns server can resolver "esha", and config reslover to it in nginx.conf

thanks for your feedback, I'll add a notice in README :)

esha- commented 9 years ago

Thanks=) Your answer is very useful for me! Also I found another way. I added in nginx.conf (http block): resolver 127.0.1.1; such as ip in my /etc/resolv.conf.

doujiang24 commented 8 years ago

Consider it resolved.

lanjingling commented 4 years ago

i have a same problem,i am use this way: modify server.properties in kafka server, add:listeners=PLAINTEXT://kafkaip:9092

takeoto commented 3 years ago

Have the same problem with docker. And [resolver 127.0.0.11 valid=10s;] doesn't help.

# cat /etc/resolv.conf 
nameserver 127.0.0.11

But I can send messages directly from the container (host in extra_hosts [yml]). Does anyone know how to solve it?