Closed shengbinxu closed 1 year ago
body is allowed to be nil. I tried to reproduce this issue, but there is no difference between empty string and nil. can you attach the output of curl?
curl -s http://127.0.0.1:8005/
@lynch1981 Thank you for your reply. There was an omission in my previous description of the problem. Only when a post request is used and the post body is not empty, will the exception be triggered.
curl -s 'http://127.0.0.1:8005' -d 'xxx'
nginx error log:
2023/10/14 20:45:21 [warn] 8688#0: *1336 upstream server temporarily disabled while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "POST / HTTP/1.1", subrequest: "/backend", upstream: "https://153.3.238.110:443/backend", host: "127.0.0.1:8005"
2023/10/14 20:45:21 [error] 8688#0: *1336 upstream timed out (60: Operation timed out) while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "POST / HTTP/1.1", subrequest: "/backend", upstream: "https://153.3.238.110:443/backend", host: "127.0.0.1:8005"
2023/10/14 20:45:21 [info] 8688#0: *1336 kevent() reported that client 127.0.0.1 closed keepalive connection
When you call ngx.location.capture_multi you set body to nil, which means no request body is required when initializing the subrequest. Therefore, the request body carried by curl -d "xxx" will not be passed to the backend. But when you set the -d parameter, the request header will contain "Content-Length: 3", which requires the backend server to receive the request body, and the server waits until it times out.
Okay, I understand a bit.
I understand the mechanism you described. And:
nginx version: openresty/1.21.4.2
When the value of the parameter body is nil, ngx.location.capture_multi will block until timeout (in this case, 5s), which is very confusing when debugging this feature. As a comparison, when the value of the parameter body is an empty string, ngx.location.capture_multi will return soon.
Expected effect: When the value of the parameter body is nil, openrest can provide error or exception prompts instead of constantly blocking.