ngx_zmq
ngx_zmq copied to clipboard
Error nginx-zmq-lua dont response data
Hi Nathan Eloe , I'm a student .Can you help me about this problem ? I using nginx version 1.9.3 and your's lib about ZMQ (https://github.com/neloe/ngx_zmq) but I have error : nginx don't response data I know your's lib run very well.
This is my config in nginx
location /test {
lua_socket_connect_timeout 600;
content_by_lua '
text="aaaa"
ngx.log(ngx.WARN, text)
local res=ngx.location.capture("http://127.0.0.1:9090/zmq",{method = ngx.HTTP_POST ,body =text})
ngx.print(res.body)
ngx.log(res.body)
';
#proxy_pass http://127.0.0.1:9090/zmq;
}
location /zmq {
zmq;
zmq_endpoint "tcp://localhost:5555"; #endpoint is required
zmq_timeout 1000; #in milliseconds, total time spent in function. optional, defaults to -1 (no timeout)
client_max_body_size 20m;
zmq_socktype REQ;
}
And this is my log when i acess test location :
*1 [lua] content_by_lua(nginx.conf:56):3: aaaa, client: 127.0.0.1, server: localhost, request: "POST /test HTTP/1.1", host: "localhost:9090"
*1 ngx_zmq got a request with content_length_n 4
*1 ngx_zmq sending aaaa to tcp://localhost:5555
*1 ngx_zmq got message of length 8
*1 ngx_zmq got message World 0
*1 ngx_zmq: alloc'ing buffer
*1 ngx_zmq: setting up to return World 0
*1 ngx_zmq: sending header
*1 ngx_zmq: completed, returning
If I acess zmq location , it's run very well , I receive reponse But when i acess test location , I don't receive reponse Thank for your help !
You've run into the same issue mentioned in the README. Posted here again for reference: https://github.com/openresty/lua-nginx-module/issues/415 .
The work around implemented in the README is to use a proxy location like proxy_pass http://127.0.0.1:9090/zmq; If you wanted to then capture that location via ngx.location.capture you could. (Meaning you need a third location that does content_by_lua)
The work around suggested by agentzh in the issue thread is to instead use one of the other libraries for url capturing, such as https://github.com/pintsized/lua-resty-http. I haven't verified that this will also solve your problem, but it is likely
When I try response a small data through zmq location, I can receive data But when I try receive a large data (~2M) . I can't receive response .
I try write this to nginx's conf but it's still dont work :( . I work with zmq location proxy_max_temp_file_size 0; proxy_buffers 8 32k;
I receive header but canot receive all data {null=[HTTP/1.1 200 OK], Server=[openresty/1.9.3.1], Connection=[keep-alive], Content-Length=[17000], Date=[Wed, 30 Sep 2015 04:18:43 GMT], Content-Type=[text/plain]}
Can you give me a advice ?
Sorry, I don't have any experience with this issue and I'm not sure on a possible fix
If you increase proxy_max_temp_file or disable proxy_buffering with off, it should work.
I recently blogged about this issue at https://dracoblue.net/dev/hanging-subrequests-in-nginx/