请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

ngx.exec出错

lua entry thread aborted: runtime error: /opt/app/lua/dep.lua:26: attempt to call ngx.exec after sending out response headers

stack traceback:

coroutine 0:

[C]: in function 'exec'

/opt/app/lua/dep.lua:26: in function </opt/app/lua/dep.lua:1>,


正在回答 回答被采纳积分+3

插入代码

1回答

Jeson 2018-04-27 10:19:19

/opt/app/lua/dep.lua 这个文件的第26行,看下什么内容,方便的话贴出来我瞅瞅

0 回复 有任何疑惑可以回复我~
  • 1 #!/usr/bin/lua
      2 clientIP = ngx.req.get_headers()["X-Real-IP"]
      3 if clientIP == nil then
      4         clientIP = ngx.req.get_headers()["X_Forwarded_For"]
      5 end
      6 if clientIP == nil then
      7         clientIP = ngx.var.remote_addr
      8 end
      9         local memcached = require "resty.memcached"
     10         local memc,err = memcached:new()
     11         if not memc then
     12                 ngx.say("failed to instantiate memc",err)
     13                 return
     14         end
     15         local ok,err = memc:connect("127.0.0.1",11211)
     16         if not ok  then
     17                 ngx.say("failed to connect: ",err)
     18                 return
     19         end
     20         local res,flags,err = memc:get(clientIP)
     21         ngx.say("value key : ",res,clientIP)
     22         if err then
     23                 ngx.say("failed to get clientIP",err)
     24         end
     25         if res == "1" then
     26                 ngx.exec("@server_test")
     27         end
     28         ngx.exec("@server")
    我也是一模一样的报错
    回复 有任何疑惑可以回复我~ 2019-09-15 15:52:54
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号