I have inherited some Lua code that communicates with a server via HTTP Request/Response. This has been running in the field for several years but I recently noticed some hangs in the timeout of the HTTP requests from the system. Each individual message has the capability to define its own timeout, but if none is set a default timeout of 30 seconds is used. I noticed on a system a couple of weeks ago that there was a hang on a timeout for about 15 minutes before it recovered and processing continued. But I am currently looking at a system that has been hung for well over 3 hours on a 30 second timeout. Here is the setup for the requests:
local socket = require "socket"
local http = require "socket.http"
local ltn12 = require "ltn12"
local ssl = require "ssl"
local try = socket.try
local protect = socket.protect
...
function serverapi.http_request(request, timeout)
... (local variable setup and logging)
socket.TIMEOUT = timeout
socket.http.TIMEOUT = timeout
result, status_code, content = socket.http.request {
url = request.url,
method = request.method,
headers = request.header,
source = ltn12.source.string(request_body),
sink = ltn12.sink.table(response_body),
}
... (receive response and process)
I should note that the hangs are erratic in terms of the messages types they hang on. So it is not consistently with one message. And, as I said, this has been deployed and running in the field for several years.
Anyone have any ideas here...? Even if it's just a way to help debug what's going on. I don't even know how to get any kind of logging in what's going on after the request is sent and it's waiting for timeout.
Thanks
socket.http.requestthat logs the timeout and one immediately after printing the status code received. So the hang must be in that call. - linsek