agusjanardana commented on issue #10807:
URL: https://github.com/apache/apisix/issues/10807#issuecomment-1897847553

   > > I have set the priority, plugin A priority is 1000 and plugin B is 500, 
but why plugin B always running first?
   > 
   > Read this: 
https://docs.api7.ai/apisix/key-concepts/plugins#plugins-execution-lifecycle 
and this: 
https://docs.api7.ai/apisix/key-concepts/plugins#plugins-execution-order
   > 
   > > it make my service error (API disabled in the context....).
   > 
   > Do you mean to say running the code to save the info to redis doesn't work 
in body filter?
   
   Thank you for responding, it looks like it can be closed. I've found the 
solution for now. So I move the redis to the log phase and using ngx.timer.at
   
   ```
   function _M.log(conf, ctx)
       local function redis_client()
           local red = redis_new()
           local timeout =  1000    -- 1sec
   
           red:set_timeouts(timeout, timeout, timeout)
   
           local sock_opts = {
               ssl = conf.ssl,
               ssl_verify = conf.ssl_verify
           }
   
           local ok, err = red:connect("host.docker.internal", 6379, sock_opts)
           if not ok then
               return false, err
           end
           return red, nil
       end                
       
       local function save_redis()
           local redis_cli = redis_client()
           redis_cli:set(clientId,  bodySession)
           redis_cli:expire(clientId, 50)
       end
       
       ngx.timer.at(0, save_redis)
   end
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to