Skip to content

Response timing out with HTTP2 on get_headers() #156

@neilp9

Description

@neilp9

Thank you @daurnimator for an excellent package and just as much, your responsive support.

We have observed an issue on Debian 9 with (latest) lua packages installed. The script we are running makes a request to our app, and responds with simple JSON response:

local https = require "http.compat.socket"
local ltn12 = require "ltn12"

local Main = {
    callflow = nil
}

function Main:run()

    local reqbody = "foo=bar&baz=boo&auth_token=xxx'
    local result, respcode = https.request {
              url="https://api.myurl.com/integrations/freeswitch/inbound/",
              method="POST",
              source=ltn12.source.string(reqbody),
        headers = {
                        ["content-type"] = "application/x-www-form-urlencoded",
                        ["content-length"] = tostring(#reqbody)
                        },
              sink = ltn12.sink.table(response)
    }
    print(result);
    print(respcode);
    print(response);
end


Main:run()

The issue we are observing is that this script times out (on the response) when using HTTP2. When we force the system to use HTTP1 by setting has_alpn variable to nil in http/tls.lua, the response comes back and the https.request function returns right away with result=1 and respcode=200.

Here's the stack trace when we force exit the script while the response is in process of timing out:

lua: /usr/local/share/lua/5.2/cqueues.lua:77: interrupted!
stack traceback:
    [C]: in function 'step'
    /usr/local/share/lua/5.2/cqueues.lua:77: in function 'step'
    /usr/local/share/lua/5.2/cqueues.lua:50: in function 'poll'
    /usr/local/share/lua/5.2/http/h2_stream.lua:1219: in function 'get_headers'
    /usr/local/share/lua/5.2/http/request.lua:597: in function 'go'
    /usr/local/share/lua/5.2/http/compat/socket.lua:153: in function 'request'
    local.lua:25: in function 'run'
    local.lua:43: in main chunk
    [C]: in ?

It appears it's stuck polling while fetching (processing?) response headers, but I can't quite understand what's happening here.

I'm hoping (assuming) we are doing something silly with this script and a simple tweak will fix. Thanks in advance.

Lua packages installed:

basexx
   0.4.1-1 (installed) - /usr/local/lib/luarocks/rocks
binaryheap
   0.4-1 (installed) - /usr/local/lib/luarocks/rocks
compat53
   0.7-1 (installed) - /usr/local/lib/luarocks/rocks
cqueues
   20171014.52-0 (installed) - /usr/local/lib/luarocks/rocks
fifo
   0.2-0 (installed) - /usr/local/lib/luarocks/rocks
http
   0.3-0 (installed) - /usr/local/lib/luarocks/rocks
inspect
   3.1.1-0 (installed) - /usr/local/lib/luarocks/rocks
lpeg
   1.0.2-1 (installed) - /usr/local/lib/luarocks/rocks
lpeg_patterns
   0.5-0 (installed) - /usr/local/lib/luarocks/rocks
lualogging
   1.3.0-1 (installed) - /usr/local/lib/luarocks/rocks
luaossl
   20190612-0 (installed) - /usr/local/lib/luarocks/rocks
luasec
   0.8-1 (installed) - /usr/local/lib/luarocks/rocks
luasocket
   3.0rc1-2 (installed) - /usr/local/lib/luarocks/rocks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions