You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "zouchengzhuo (via GitHub)" <gi...@apache.org> on 2023/04/28 10:53:43 UTC

[GitHub] [apisix] zouchengzhuo commented on issue #9214: bug: In a streaming plug-in, when the client connects concurrently, or when the ngx.socket.tcp is created concurrently in the plugin, there is a certain probability that the tcp read buffer accumulates data, but the receive method of ngx.req.socket block continuously.

zouchengzhuo commented on issue #9214:
URL: https://github.com/apache/apisix/issues/9214#issuecomment-1527381835

   > sorry. I not found this usage at APISIX project.
   > 
   > ```
   > ~/w/apisix *master> ack 'socket.tcp' apisix/stream/plugins/
   > ~/w/apisix *master> ack 'ngx.req.socket' apisix/stream/
   > apisix/stream/plugins/mqtt-proxy.lua
   > 131:    local sock = ngx.req.socket()
   > ```
   > 
   > and
   > 
   > > When the raw argument is true, it is required that no pending data from any previous [ngx.say](https://github.com/openresty/lua-nginx-module#ngxsay), [ngx.print](https://github.com/openresty/lua-nginx-module#ngxprint), or [ngx.send_headers](https://github.com/openresty/lua-nginx-module#ngxsend_headers) calls exists. So if you have these downstream output calls previously, you should call [ngx.flush(true)](https://github.com/openresty/lua-nginx-module#ngxflush) before calling ngx.req.socket(true) to ensure that there is no pending output data. If the request body has not been read yet, then this "raw socket" can also be used to read the request body.
   
   There is the same problem when using ngx.req.socket(),the receive queue of tcp will be blocked when using sock:receive. 
   
   when using  sock:receiveany, the receive queue of tcp will not blocked,  but in this case, i have to manage the buffer myself.
   
   when using sock:receive, there may be some problems with the coroutine scheduling, causing the main coroutine to fail to resume.
   


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org