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

在使用openResty和lua构建nginx分发层时,遇到set_keepalive错误,报错信息为lua entry thread aborted: bad argument #2 to ‘set_keepalive’ (number expected, got nil)。解决方法包括在lua脚本中添加keepalive=false参数,或者设置keepalive_timeout。经测试,设置keepalive=false的方法更有效。" 60958633,5143179,C语言与串行通信:深入理解串口操作,"['C语言', '串行通信', 'Linux', '通信协议', '串口操作']

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

使用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 </usr/hello/lua/hello.lua:1>, 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,
ke

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值