I use lua-resty-http to perform an external API query. Many times I need to run the script twice. The first time the request times out with the error below, the second time I get the expected response. I tried increasing the resty.http timeout value several times via set_timeout() to no avail. In a situation where the remote host resets the connection, how can I gracefully handle that error?
2014/07/16 07:36:13 [error] 10742#0: *2176281 lua tcp socket read timed out,
client: 1.2.3.4, server: acme.com, request: "GET /script
HTTP/1.1", host: "acme.com"
2014/07/16 07:36:13 [error] 10742#0: *2176281 lua entry thread aborted: runtime
error: /usr/local/src/lua-resty-http/lib/resty/http.lua:601: bad argument #1 to
'pairs' (table expected, got nil)
stack traceback:
coroutine 0:
[C]: in function 'pairs'
/usr/local/src/lua-resty-http/lib/resty/http.lua:601: in function
'__index'
/opt/openresty/nginx/conf/script.lua:171: in function 'HTTPClient'
/opt/openresty/nginx/conf/script.lua:327: in function 'main'
/opt/openresty/nginx/conf/script.lua:349: in function
</opt/openresty/nginx/conf/script.lua:1>, client: 1.2.3.4, server:
acme.com, request: "GET /script HTTP/1.1", host: "acme.com"
2014/07/16 07:36:13 [info] 10742#0: *2176281 recv() failed (104: Connection
reset by peer) while sending to client, client: 1.2.3.4, server:
acme.com, request: "GET /script HTTP/1.1", upstream:
"fastcgi://unix:/var/run/php5-fpm.sock", host: "acme.com"
thanks,
-G