[总结]openresty 限流count.lua:53:attempt to call method 'expire' (a nil value)报错排查,openrestycount.lua


        最近在研究openresty 1.13.6.1版本限流方案,参考该文档:https://github.com/openresty/lua-resty-limit-traffic/blob/master/lib/resty/limit/count.md 编写了一个时间窗内调用总次数限流Demo,可是测试时,遇到如下问题:


2018/03/20 12:38:05 [error] 33074#814554: *1 lua entry thread aborted: runtime error: ...l/Cellar/openresty/1.13.6.1/lualib/resty/limit/count.lua:53: attempt to call method 'expire' (a nil value)

stack traceback:

coroutine 0:

...l/Cellar/openresty/1.13.6.1/lualib/resty/limit/count.lua: in function 'incoming'

conf/limit_frequency.lua:18: in function 'incoming'

...IdeaProjects/luaapp/work/conf/access_limit_frequency.lua:8: in function <...IdeaProjects/luaapp/work/conf/access_limit_frequency.lua:1>, client: 10.202.97.23, server: , request: "GET /limitFrequency HTTP/1.1", host: "10.202.97.23:8080"



报错的直接原因是:openresty/1.13.6.1/lualib/resty/limit/count.lua:53: attempt to call method 'expire' (a nil value)

当时把该错误google了一把,没有找到任何解决方法。于是乎把该错误发到google 讨论组里,https://groups.google.com/forum/#!forum/openresty 很快就有人回应了。原来是我没有在http{} 配置块内添加resty.core依赖: 

   init_by_lua_block {

        require "resty.core"

    }


其实参考文档内有说明依赖resty.core,且原文demo中也有配置init_by_lua_block……

怪自己太粗心,原文文档都没仔细阅读。


相关内容

    暂无相关文章