Kong / lua-resty-dns-client

Lua DNS client, load balancer, and utility library
http://kong.github.io/lua-resty-dns-client/topics/README.md.html
Apache License 2.0
152 stars 52 forks source link

[Question] To be able to import this package I need to setup nginx config in my PC, is that correct? #132

Closed Rezwanul-Haque closed 3 years ago

Rezwanul-Haque commented 3 years ago

I recently tried to use this package to resolve the SRV record but in my local Lua file I was unable to import this package as it always throws this error saying

lua: /usr/local/share/lua/5.3/resty/dns/utils.lua:18: attempt to index a nil value (global 'ngx')
stack traceback:
        /usr/local/share/lua/5.3/resty/dns/utils.lua:18: in main chunk
        [C]: in function 'require'
        /usr/local/share/lua/5.3/resty/dns/client.lua:23: in main chunk
        [C]: in function 'require'
        dns_resolver.lua:1: in main chunk
        [C]: in ?
locao commented 3 years ago

Hi @Rezwanul-Haque! Yes, this package is meant to be used when embedding Lua code in Nginx using lua-nginx-module, you can't use it in a standalone script. Please, refer to OpenResty docs to learn more.