Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proxy_response cant forward the app heartbeat packet to client #28

Closed
guanglinlv opened this issue Jan 28, 2015 · 4 comments
Closed

proxy_response cant forward the app heartbeat packet to client #28

guanglinlv opened this issue Jan 28, 2015 · 4 comments

Comments

@guanglinlv
Copy link

hi,
I find proxy_response cant send the app heartbeat packet(only 6 bytes) to client immediately because using ngx.print. so i have to invoke ngx.flush after print. may i have your some good advice?
see http://wiki.nginx.org/HttpLuaModule#ngx.flush

@pintsized
Copy link
Member

Hi. Well proxy_response is really just a convenience function, requested by users. If you need greater control, then it's quite trivial to implement your own version, and decide to call ngx.flush when you wish. If your app has a 6 byte heartbeat then you can test for that in your code, and decide to flush this immediately. Sounds like you're doing this already?

@guanglinlv
Copy link
Author

yes,i had to invoked ngx.flush for my streaming output, but I'm not sure that delaying send is decided by ngx.print or nginx, how to config it ?

@pintsized
Copy link
Member

It might be best to ask on the OpenResty mailing list, since others may have more experience with this than me. But my understanding is that ngx.print will push data to the Nginx output chain and it's up to Nginx to buffer however it wants. If however you call ngx.flush in synchronous mode after ngx.print, then the print effectively becomes synchronous (though remaining non-blocking to the Nginx event loop), and the data is sent to the system send buffer more directly.

ngx.print(chunk)
ngx.flush(true)

Beyond this, it is up to Nginx to get those bytes out on the wire, and I'm not sure if there's any more control available for this.

https://github.com/openresty/lua-nginx-module#ngxflush
https://github.com/openresty/lua-nginx-module#ngxprint

@guanglinlv
Copy link
Author

ok, thanks for your patiently replay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants