HttpLuaModule create asynchronous subrequests
guido at motrixi.com
Fri Nov 14 19:20:55 UTC 2014
On Thu, Nov 13, 2014 at 5:24 PM, Yichun Zhang (agentzh) <agentzh at gmail.com>
> On Wed, Nov 12, 2014 at 12:20 PM, Guido Accardo wrote:
> > Here, prod response is sent immediately as I want and dev receives the
> > traffic but the connection is closed the I got a Broken Pipe (which makes
> > sense).
> For this error, maybe you should configure
> proxy_ignore_client_abort on;
> for your dev location with proxy_pass.
> But using ngx.eof() for this will still introduce extra delay for the
> subsequent requests on the current downstream connection when HTTP
> keepalive or HTTP pipelining is enabled.
Using "proxy_ignore_client_abort on;" as you suggested worked for me.
>From the doc of proxy_ignore_client_abort:
" ... Determines whether the connection with a proxied server should be
closed when a client closes the connection without waiting for a response
So basically I'm discarding dev's responses ?
> > Is there a way to do capture calls in a asynchronous mode or to achieve
> > in other way?
> The recommended way is to use cosocket-based http library like Brian
> Akins's lua-resty-http-simple  (instead of subrequests and
> ngx_proxy) in a 0-delay timer created by ngx.timer.at()  (instead
> of the ngx.eof hack).
I'm going for this solution, the ugly hack will be my second option but
this seems great.
> BTW, it's recommended to join the openresty-en mailing list  for
> such ngx_lua related questions that way you may get more responses and
> get responses sooner.
I'll definitely do it!
> For your very use case, maybe lower level tools like tcpcopy  is a
> better fit? Not sure though :)
I gave it a try, also https://www.npmjs.org/package/duplicator and traffic
mirroring with iptables TEE module, but anyway the library that you
>  https://github.com/bakins/lua-resty-http-simple
>  https://github.com/openresty/lua-nginx-module#ngxtimerat
>  https://groups.google.com/group/openresty-en
>  https://github.com/session-replay-tools/tcpcopy
> nginx mailing list
> nginx at nginx.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the nginx