Hi all,
I'm using openresty from short time...
Why this code work well with "content_by_lua" and in external file with "content_by_lua_file" go every time in timeout?
----- START CODE -----
local sock = ngx.socket.tcp()
sock:settimeout(2000) -- one second timeout
local ok, err = sock:connect("www.googleapis.com", 443)
if not ok then
ngx.say("###failed to connect: ", err)
return
end
ngx.say("###connected: ", ok)
local sess, err = sock:sslhandshake()
if not sess then
ngx.say("###failed to do SSL handshake: ", err)
return
end
ngx.say("###ssl handshake: ", type(sess))
local req = "GET /oauth2/v3/tokeninfo?access_token= HTTP/1.1\\r\\nHost: www.googleapis.com\\r\\nConnection: close\\r\\n\\r\\n"
local bytes, err = sock:send(req)
if not bytes then
ngx.say("###failed to send http request: ", err)
return
end
local line, err = sock:receive("*a")
if not line then
ngx.say("###failed to recieve response status line: ", err)
return
end
ngx.say(line)
local ok, err = sock:close()
----- END CODE -----
- Stefano