Closed rucciva closed 6 years ago
This might be related to the global patches that override the ngx socket functions. See https://github.com/Kong/kong/blob/master/kong/globalpatches.lua#L308-L309 for example. The UDP code checks for unix:
but the TCP code does not. Though I would have expected a different stacktrace if that were the case.
hi @Tieske, i've tried to modify the tcp_resolve_connect
to mimic the udp_resolve_setpeername
yet it showed the same error
i think it is also related to https://github.com/openresty/lua-nginx-module/issues/860. So i changed the patch into this and it works
local function tcp_resolve_connect(sock, host, port, sock_opts)
if sub(host, 1, 5) == 'unix:' then
target_ip = host -- unix domain socket, so just maintain the named values
else
target_ip, target_port = toip(host, port)
if not target_ip then
return nil, '[toip() name lookup failed]: ' .. tostring(target_port) -- err
end
end
if type(port) ~= 'number' then
if not sock_opts then
return old_tcp_connect(sock, target_ip)
end
return old_tcp_connect(sock, target_ip, sock_opts)
end
if not sock_opts then
return old_tcp_connect(sock, target_ip, target_port)
end
return old_tcp_connect(sock, target_ip, target_port, sock_opts)
end
Thanks for pointing that out @Tieske
@rucciva Mind sending a PR?
sure, will do it soon
closing this in favour of #3633
NOTE: GitHub issues are reserved for bug reports only. For anything else, please join the conversation in Kong Nation https://discuss.konghq.com/.
Please read the CONTRIBUTING.md guidelines to learn on which channels you can seek for help and ask general questions:
https://github.com/Kong/kong/blob/master/CONTRIBUTING.md#where-to-seek-for-help
Summary
tcpsocket return bad argument #2 to 'connect' (number expected, got nil) whan calling
connect
method with UNIX socket address, unlike what stated in ngx.socket.tcp documentation,Steps To Reproduce
connect
method by ommiting theport
parameter when thehost
start withunix:
Additional Details & Logs
<KONG_PREFIX>/logs/error.log
)Operating system Linux Ubuntu 16.04 (docker)
Screenshot