当前位置:   article > 正文

记录nginx 使用lua 转发消息到kafka错误_a client request body is buffered to a temporary f

a client request body is buffered to a temporary file /usr/local/openresty/n

错误日志

2021/05/14 15:28:59 [warn] 19924#19924: *1 a client request body is buffered to a temporary file /usr/local/openresty/nginx/client_body_temp/0000000001, client: 192.168.244.107, server: localhost, request: “POST /ife HTTP/1.1”, host: “192.168.244.214:8887”
2021/05/14 15:29:00 [error] 19924#19924: *3 lua entry thread aborted: runtime error: /usr/local/openresty/lualib/resty/kafka/sendbuffer.lua:63: attempt to get length of local ‘msg’ (a nil value)
stack traceback:
coroutine 0:
/usr/local/openresty/lualib/resty/kafka/sendbuffer.lua: in function ‘add’
/usr/local/openresty/lualib/resty/kafka/producer.lua:254: in function </usr/local/openresty/lualib/resty/kafka/producer.lua:233>, context: ngx.timer, client: 192.168.244.107, server: 0.0.0.0:8887

原因 - nginx client_body_buffer_size 默认16K

当请求数据大于16K时,会写道临时文件, 导致lua中获取不到消息
local msg=ngx.req.get_body_data() //这里msg将会是空的

解决办法 - 设置client_body_buffer_size

在nginx.conf 中设置
client_body_buffer_size 500k;

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/192718
推荐阅读
相关标签
  

闽ICP备14008679号