hi, 春哥,在使用Tengine/2.1.2(nginx/1.6.2) +ngx_lua_module/0.10.6的时候,发现HTTP2.0 post请求在获取body转发时会hung,请问怎么破?

230 views
Skip to first unread message

liu...@xiaomi.com

unread,
Oct 3, 2016, 4:49:20 AM10/3/16
to openresty
hi, 春哥,在使用Tengine/2.1.2(nginx/1.6.2) +ngx_lua_module/0.10.6的时候,发现HTTP2.0 post请求在获取body转发时会hung,请问怎么破?

同样的测试在http1.1上, get和post的请求是可以支持的。
在http2.0上,只有get请求成功执行了subrequest请求,post请求在跳转到新的location阶段hung住了
以下是lua打印出来的nginx日志,加粗的是请求的body

2016/10/03 16:42:31 [error] 22001#0: *21966 [lua] jumpProduction.lua:37: test>>>>1, post subrequest start transId=9IAwC2gOwLuSYxdcF7t55g%3D%3D&sid=57HmiVnZSSNLVL9djSU86A%3D%3D&birthday=XZDLdBUI5XlTQVApaEl6yw%3D%3D&signature=a1ELe6Gv1g6AqKSBLE8OafV5ISo%3D&userId=lXpmyTbWVH9bXY29AOOIrA%3D%3D, client: 10.235.115.33, server: test.com, request: "POST /pass/v2/safe/user/profile HTTP/2.0", host: "test.com"

YuanSheng Wang

unread,
Oct 13, 2016, 3:32:52 AM10/13/16
to open...@googlegroups.com
2016-10-03 16:49 GMT+08:00 <liu...@xiaomi.com>:
hi, 春哥,在使用Tengine/2.1.2(nginx/1.6.2) +ngx_lua_module/0.10.6的时候,发现HTTP2.0 post请求在获取body转发时会hung,请问怎么破?


因为 nginx  c module 和 nginx core 的代码咬合关系是比较多的,目前最新版本是 nginx-1.11.2 + ngx_lua-0.10.6 ,但是 Tengine 中携带的 nginx 版本太老了。

这里推荐换用 openresty 整包,否则你只能看源码追问题了。

 
同样的测试在http1.1上, get和post的请求是可以支持的。
在http2.0上,只有get请求成功执行了subrequest请求,post请求在跳转到新的location阶段hung住了
以下是lua打印出来的nginx日志,加粗的是请求的body

2016/10/03 16:42:31 [error] 22001#0: *21966 [lua] jumpProduction.lua:37: test>>>>1, post subrequest start transId=9IAwC2gOwLuSYxdcF7t55g%3D%3D&sid=57HmiVnZSSNLVL9djSU86A%3D%3D&birthday=XZDLdBUI5XlTQVApaEl6yw%3D%3D&signature=a1ELe6Gv1g6AqKSBLE8OafV5ISo%3D&userId=lXpmyTbWVH9bXY29AOOIrA%3D%3D, client: 10.235.115.33, server: test.com, request: "POST /pass/v2/safe/user/profile HTTP/2.0", host: "test.com"

--
--
邮件来自列表“openresty”,专用于技术讨论!
订阅: 请发空白邮件到 openresty+subscribe@googlegroups.com
发言: 请发邮件到 open...@googlegroups.com
退订: 请发邮件至 openresty+unsubscribe@googlegroups.com
归档: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
教程: http://openresty.org/download/agentzh-nginx-tutorials-zhcn.html



--

YuanSheng Wang
---------------------------------------
OpenResty lover ^_^

liu...@xiaomi.com

unread,
Oct 21, 2016, 2:29:03 AM10/21/16
to openresty
试了一下nginx最新版本,问题依旧存在。期望是进入到location ^~ /local, 但日志输出的uri并没有出现这个location
版本信息:
nginx version: nginx/1.11.5
built by gcc 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC)
built with OpenSSL 1.0.2j  26 Sep 2016
TLS SNI support enabled
configure arguments: --prefix=/home/work/nginx/ --with-http_realip_module --with-http_gzip_static_module --with-http_addition_module --with-http_ssl_module --with-http_v2_module --with-http_sub_module --with-http_stub_status_module --without-mail_smtp_module --without-mail_imap_module --without-mail_pop3_module --with-pcre=./src/pcre-8.32 --add-module=./src/headers-more-nginx-module-master --add-module=./src/lua-nginx-module --with-pcre-jit --with-openssl-opt='-O3 -fPIC' --with-openssl=./src/openssl-1.0.2j

nginx lua block:
ngx.req.read_body()
    args = ngx.req.get_body_data()
    ngx.log(ngx.ERR, "test>>>>1, post subrequest start" .. args)
    res = ngx.location.capture("/localPost" .. ngx.var.request_uri,{ method = ngx.HTTP_POST , body = args })
    ngx.log(ngx.ERR, "test>>>>2, post subrequest end ")


调试日志:

2016/10/21 13:58:55 [emerg] 5462#0: *1175 ngx_http_core_run_phases working., client: 192.168.33.133, server: test.com, request: "POST /pass/access?_dc=1477030330529 HTTP/2.0", host: "test.com", referrer: "https://test.com/pass/serviceLogin"
2016/10/21 13:58:55 [emerg] 5462#0: *1175 ngx_http_core_run_phases nginx_ok, client: 192.168.33.133, server: test.com, request: "POST /pass/access?_dc=1477030330529 HTTP/2.0", host: "test.com", referrer: "https://test.com/pass/serviceLogin"
2016/10/21 13:58:55 [error] 5462#0: *1175 [lua] jumpProduction.lua:37: test>>>>1, post subrequest start_json=true&callback=https%3A%2F%2Ftest.com&sid=passport&qs=%253Fsid%253Dpassport&_sign=2%26V1_passport%26wqS4omyjALxMm%2F%2F3wLXcVcITjEc%3D&serviceParam=%7B%22checkSafePhone%22%3Afalse%7D&user=98806570&hash=D1A3F64E20C48EF7840B5777A7677E49, client: 192.168.33.133, server: test.com, request: "POST /pass/access?_dc=1477030330529 HTTP/2.0", host: "test.com", referrer: "https://test.com/pass/serviceLogin"
2016/10/21 13:58:55 [emerg] 5462#0: *1175 lua location capture, uri:"/pass/access" c:1, client: 192.168.33.133, server: test.com, request: "POST /pass/access?_dc=1477030330529 HTTP/2.0", host: "test.com", referrer: "https://test.com/pass/serviceLogin"
2016/10/21 13:58:55 [emerg] 5462#0: *1175 queries query: top 2, client: 192.168.33.133, server: test.com, request: "POST /pass/access?_dc=1477030330529 HTTP/2.0", host: "test.com", referrer: "https://test.com/pass/serviceLogin"
2016/10/21 13:58:55 [emerg] 5462#0: *1175 queries query uri: 3, client: 192.168.33.133, server: test.com, request: "POST /pass/access?_dc=1477030330529 HTTP/2.0", host: "test.com", referrer: "https://test.com/pass/serviceLogin"
2016/10/21 13:58:55 [emerg] 5462#0: *1175 first arg in first query: string, client: 192.168.33.133, server: test.com, request: "POST /pass/access?_dc=1477030330529 HTTP/2.0", host: "test.com", referrer: "https://test.com/pass/serviceLogin"
2016/10/21 13:58:55 [emerg] 5462#0: *1175 verify ctx, client: 192.168.33.133, server: test.com, request: "POST /pass/access?_dc=1477030330529 HTTP/2.0", host: "test.com", referrer: "https://test.com/pass/serviceLogin"
2016/10/21 13:58:55 [emerg] 5462#0: *1175 verify psr_data, client: 192.168.33.133, server: test.com, request: "POST /pass/access?_dc=1477030330529 HTTP/2.0", host: "test.com", referrer: "https://test.com/pass/serviceLogin"
2016/10/21 13:58:55 [emerg] 5462#0: *1175 inter ngx_http_lua_subrequest method, client: 192.168.33.133, server: test.com, request: "POST /pass/access?_dc=1477030330529 HTTP/2.0", host: "test.com", referrer: "https://test.com/pass/serviceLogin"
2016/10/21 13:58:55 [emerg] 5462#0: *1175 get result of ngx_http_lua_subrequest method:0, client: 192.168.33.133, server: test.com, request: "POST /pass/access?_dc=1477030330529 HTTP/2.0", host: "test.com", referrer: "https://test.com/pass/serviceLogin"
2016/10/21 13:58:55 [emerg] 5462#0: *1175 inter ngx_http_lua_adjust_subrequest method, client: 192.168.33.133, server: test.com, request: "POST /pass/access?_dc=1477030330529 HTTP/2.0", host: "test.com", referrer: "https://test.com/pass/serviceLogin"
2016/10/21 13:58:55 [emerg] 5462#0: *1175 get result of ngx_http_lua_adjust_subrequest method:0, client: 192.168.33.133, server: test.com, request: "POST /pass/access?_dc=1477030330529 HTTP/2.0", host: "test.com", referrer: "https://test.com/pass/serviceLogin"




liu...@xiaomi.com於 2016年10月3日星期一 UTC+8下午4時49分20秒寫道:

liu...@xiaomi.com

unread,
Oct 21, 2016, 2:38:08 AM10/21/16
to openresty
附件添加了ngx_lua_subrequest的日志输出信息。

liu...@xiaomi.com於 2016年10月3日星期一 UTC+8下午4時49分20秒寫道:
ngx_http_lua_subrequest.c
Reply all
Reply to author
Forward
0 new messages