使用openResty搭建nginx分发层遇到set_keepalive报错问题解决

使用openResty搭建nginx分发层遇到set_keepalive报错问题解决

|[error] 24164#0: *462 lua entry thread aborted: runtime error: /usr/hello/lualib/resty/http.lua:909: bad argument #2 to ‘set_keepalive’ (number expected, got nil)
stack traceback:
coroutine 0:
[C]: in function ‘set_keepalive’
/usr/hello/lualib/resty/http.lua:909: in function ‘request_uri’
/usr/hello/lua/hello.lua:16: in function , client: 192.168.126.3, server: _, request: “GET /hello?productId=1&requestPath=hello HTTP/1.1”, host: “192.168.126.128”

看亿级流量详情页,使用nginx+lua搭建nginx的分发层遇到这个问题,
纠结了两天,发现需要设置set_keepalive,两种方法:
(1)在hello.lua脚本中
| local http = require “resty.http”
local httpc = http:new()
local resp, err = httpc:request_uri(backend, {
method = “GET”,
path = requestPath,
keepalive = false
})

加上keepalive=false
(2),在hello.lua脚本中:
local resp, err = httpc:request_uri(backend, {
method = “GET”,
path = requestPath,
keepalive_timeout = 1
})
但是测试发现第二种方法不好使,算了,暂且用第一种方法吧
欢迎微信探讨:18566765253(穆)

你可能感兴趣的:(问题解决)