I have been thoroughly enjoying teaching my haproxy new tricks with Lua,
but trying sockets for the first time, using 1.6-dev4, I'm confused by what
I see. The behavior is the same whether I try this in "task" or "action"
context.
I see this in the release notes:
- BUG/MEDIUM: lua: outgoing connection was broken since 1.6-dev2
....which seems applicable, but in 1.6-dev4-61d301f I'm not having luck with
outgoing sockets.
I wouldn't be surprised if I'm doin' it wrong. Another perspective would
be appreciated.
function tricky_socket()
local sock = core.tcp();
sock:settimeout(3);
core.log(core.alert,"calling connect()\n");
local connected, con_err = sock:connect("x.x.x.x",80);
core.log(core.alert,"returned from connect()\n");
if con_err ~= nil then
core.log(core.alert,"connect() failed with error: '" .. con_err
... "'\n");
end
...
I removed the rest, since the above captures the essence of the problem.
This apparently fails:
Sep 1 14:15:41 localhost haproxy[25480]: calling connect()
Sep 1 14:15:44 localhost haproxy[25480]: returned from connect()
Sep 1 14:15:44 localhost haproxy[25480]: connect() failed with error:
'Can't connect'
However, it actually did make a connection, because now I have this:
tcp 0 0 10.10.10.10:43368 x.x.x.x:80 TIME_WAIT
In fact, during the 3 seconds, it was ESTABLISHED. The other side saw the
connection, too:
Sep 1 14:15:44 localhost haproxy[1033]: 10.10.10.10:43368
[01/Sep/2015:14:15:41.680] ... -1/-1/-1/-1/3001 400 ... CR-- "<BADREQ>"
Network issues can be reasonably ruled out, since I can talk to the far end
with curl and http-over-telnet, no problem... and, in fact, the original
destination wasn't another haproxy -- I switched the destination so I could
confirm what I suspected... which was that the socket is connecting, almost
immediately, yet for reasons that aren't clear, it doesn't seem to realize
it.
Ubuntu 14.04.2 LTS 3.13.0-58-generic #97-Ubuntu SMP
HA-Proxy version 1.6-dev4-61d301f 2015/08/30
Lua 5.3.1 Copyright (C) 1994-2015 Lua.org, PUC-Rio
make TARGET=linux2628 CPU=native USE_PCRE=1 USE_OPENSSL=1 USE_ZLIB=1 \
USE_LUA=yes LUA_LIB=/opt/lua53/lib/ LUA_INC=/opt/lua53/include/
LDFLAGS=-ldl
but trying sockets for the first time, using 1.6-dev4, I'm confused by what
I see. The behavior is the same whether I try this in "task" or "action"
context.
I see this in the release notes:
- BUG/MEDIUM: lua: outgoing connection was broken since 1.6-dev2
....which seems applicable, but in 1.6-dev4-61d301f I'm not having luck with
outgoing sockets.
I wouldn't be surprised if I'm doin' it wrong. Another perspective would
be appreciated.
function tricky_socket()
local sock = core.tcp();
sock:settimeout(3);
core.log(core.alert,"calling connect()\n");
local connected, con_err = sock:connect("x.x.x.x",80);
core.log(core.alert,"returned from connect()\n");
if con_err ~= nil then
core.log(core.alert,"connect() failed with error: '" .. con_err
... "'\n");
end
...
I removed the rest, since the above captures the essence of the problem.
This apparently fails:
Sep 1 14:15:41 localhost haproxy[25480]: calling connect()
Sep 1 14:15:44 localhost haproxy[25480]: returned from connect()
Sep 1 14:15:44 localhost haproxy[25480]: connect() failed with error:
'Can't connect'
However, it actually did make a connection, because now I have this:
tcp 0 0 10.10.10.10:43368 x.x.x.x:80 TIME_WAIT
In fact, during the 3 seconds, it was ESTABLISHED. The other side saw the
connection, too:
Sep 1 14:15:44 localhost haproxy[1033]: 10.10.10.10:43368
[01/Sep/2015:14:15:41.680] ... -1/-1/-1/-1/3001 400 ... CR-- "<BADREQ>"
Network issues can be reasonably ruled out, since I can talk to the far end
with curl and http-over-telnet, no problem... and, in fact, the original
destination wasn't another haproxy -- I switched the destination so I could
confirm what I suspected... which was that the socket is connecting, almost
immediately, yet for reasons that aren't clear, it doesn't seem to realize
it.
Ubuntu 14.04.2 LTS 3.13.0-58-generic #97-Ubuntu SMP
HA-Proxy version 1.6-dev4-61d301f 2015/08/30
Lua 5.3.1 Copyright (C) 1994-2015 Lua.org, PUC-Rio
make TARGET=linux2628 CPU=native USE_PCRE=1 USE_OPENSSL=1 USE_ZLIB=1 \
USE_LUA=yes LUA_LIB=/opt/lua53/lib/ LUA_INC=/opt/lua53/include/
LDFLAGS=-ldl