local sock = ngx.req.socket(true) sock:settimeout(2000) -- one second timeout local line, err, partial = sock:receive() if not line then ngx.say("failed to read a line: ", err) --sock::close() return end ngx.say("successfully read a line: ", line)