683
=== TEST 17: re-connect after timed out
686
lua_socket_connect_timeout 100ms;
687
resolver $TEST_NGINX_RESOLVER;
691
local sock = ngx.socket.tcp()
692
local ok, err = sock:connect("agentzh.org", 12345)
694
ngx.say("1: failed to connect: ", err)
696
local ok, err = sock:connect("127.0.0.1", ngx.var.server_port)
698
ngx.say("2: failed to connect: ", err)
702
ngx.say("2: connected: ", ok)
706
ngx.say("1: connected: ", ok)
712
1: failed to connect: timeout
715
lua tcp socket connect timeout: 100
716
lua tcp socket connect timed out
720
=== TEST 18: re-send on the same object after a send timeout happens
723
lua_socket_send_timeout 100ms;
724
resolver $TEST_NGINX_RESOLVER;
727
local sock = ngx.socket.tcp()
728
local ok, err = sock:connect("127.0.0.1", $TEST_NGINX_MEMCACHED_PORT)
730
ngx.say("failed to connect: ", err)
734
ngx.say("connected: ", ok)
737
bytes, err = sock:send("get helloworld!")
739
ngx.say("sent: ", bytes)
741
ngx.say("failed to send: ", err)
742
bytes, err = sock:send("blah")
744
ngx.say("failed to send again: ", err)
753
F(ngx_http_lua_socket_send) {
761
if (active && pid() == target()) {
767
failed to send: timeout
768
failed to send again: closed
770
lua tcp socket send timeout: 100
771
lua tcp socket connect timeout: 60000
772
lua tcp socket write timed out
776
=== TEST 19: abort when upstream sockets pending on writes
779
resolver $TEST_NGINX_RESOLVER;
782
local sock = ngx.socket.tcp()
783
local ok, err = sock:connect("127.0.0.1", $TEST_NGINX_MEMCACHED_PORT)
785
ngx.say("failed to connect: ", err)
789
ngx.say("connected: ", ok)
792
ngx.thread.spawn(function () ngx.sleep(0.001) ngx.say("done") ngx.exit(200) end)
794
bytes, err = sock:send("get helloworld!")
796
ngx.say("sent: ", bytes)
798
ngx.say("failed to send: ", err)
806
F(ngx_http_lua_socket_send) {
814
if (active && pid() == target()) {
822
lua tcp socket send timeout: 100
823
lua tcp socket connect timeout: 60000
825
lua tcp socket write timed out
829
=== TEST 20: abort when downstream socket pending on writes
832
resolver $TEST_NGINX_RESOLVER;
837
local sock, err = ngx.req.socket(true)
839
ngx.say("failed to acquire the req socket: ", err)
844
ngx.thread.spawn(function ()
846
ngx.log(ngx.WARN, "quitting request now")
850
bytes, err = sock:send("e\\r\\nget helloworld!")
852
ngx.say("sent: ", bytes)
854
ngx.say("failed to send: ", err)
862
F(ngx_http_lua_socket_send) {
870
if (active && pid() == target()) {
876
lua tcp socket send timeout: 100
879
lua tcp socket write timed out