Welcome! Log In Create A New Profile

Advanced

LUA fails to connect to unix domain socket under nginx

June 17, 2013 10:12AM
connect() fails with error "(91: Protocol wrong type for socket)"
i use nginx 1.4.1 with lua module version 0.82 and lua on system ver 5.1.4, on CentOS linux version 6.3

LUA code in nginx.conf:
---------------------------------
location /uds {
content_by_lua '
local sock = ngx.socket.udp()
local ok, err = sock:setpeername("unix:/tmp/testSocket")
if not ok then
ngx.say("failed to connect to uds: ", err)
return
end
ngx.say("successfully connected to uds")
sock:send("abcd")
sock:close()
';
}

---------------------------------

nginx debug log:
---------------------------------
2013/06/17 17:08:45 [debug] 21375#0: *3 access phase: 7
2013/06/17 17:08:45 [debug] 21375#0: *3 access phase: 8
2013/06/17 17:08:45 [debug] 21375#0: *3 post access phase: 9
2013/06/17 17:08:45 [debug] 21375#0: *3 lua content handler, uri:"/uds" c:1
2013/06/17 17:08:45 [debug] 21375#0: *3 posix_memalign: 0000000000798200:4096 @16
2013/06/17 17:08:45 [debug] 21375#0: *3 lua reset ctx
2013/06/17 17:08:45 [debug] 21375#0: *3 lua creating new thread
2013/06/17 17:08:45 [debug] 21375#0: *3 http cleanup add: 0000000000792088
2013/06/17 17:08:45 [debug] 21375#0: *3 lua run thread, top:0 c:1
2013/06/17 17:08:45 [debug] 21375#0: *3 lua udp socket network address given directly
2013/06/17 17:08:45 [debug] 21375#0: *3 lua udp socket resolve retval handler
2013/06/17 17:08:45 [debug] 21375#0: *3 UDP socket 11
2013/06/17 17:08:45 [debug] 21375#0: *3 datagram unix domain socket autobind
2013/06/17 17:08:45 [debug] 21375#0: *3 connect to unix:/tmp/sbbSocket, fd:11 #4
2013/06/17 17:08:45 [crit] 21375#0: *3 connect() failed (91: Protocol wrong type for socket), client: 127.0.0.1, server: www.test.com, request: "GET /uds HTTP/1.1", host: "test.com"
2013/06/17 17:08:45 [debug] 21375#0: *3 http cleanup add: 00000000007983E8
2013/06/17 17:08:45 [debug] 21375#0: *3 lua udp socket connect: -1
2013/06/17 17:08:45 [debug] 21375#0: *3 lua udp socket error retval handler
2013/06/17 17:08:45 [debug] 21375#0: *3 lua allocate new chainlink and new buf of size 57, cl:0000000000798400
---------------------------------


tnx in advance,

Gad
Subject Author Posted

LUA fails to connect to unix domain socket under nginx

gadh June 17, 2013 10:12AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 219
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready