2 years ago
#66013
Franz
Upload payload body to Spring Cloud Gateway before making proxy or downstream calls?
Original question (Please view edit):
In nginx
, there is module directive called proxy_read_timeout
: http://nginx.org/en/docs/http/ngx_http_proxy_module.html - By default, it is 60s
, and as I understand it, this is only for calls between nginx
and the proxied service
like so:
Client (Uploads a big file) -> nginx Gateway -> (Waits 60 seconds) -> Downstream Service
In Spring Cloud Gateway, I'm familiar you can set this:
spring:
cloud:
gateway:
httpclient:
response-timeout: 60s
or per route using metadata
like this:
.metadata(RESPONSE_TIMEOUT_ATTR, 60)
However, this seems to set the response timeout for the entire call chain, like so:
Client (Uploads a big file) -> (Waits 60 seconds) Spring Cloud Gateway -> Downstream Service
Is there a way to set a response timeout only between SCG and the proxied service but not the whole request? Or perhaps dynamically or programatically set the response timeout on between downstream calls?
I would like to limit the response time of the proxied call, but if a client is uploading a big file, it might take longer depending on their upload speed.
Edit: After some more research, proxy_read_timeout
is behaving the same as SCG's response-timeout
- The issue has been narrowed down to this config (we use openresty/lua-nginx-module)
lua_need_request_body on;
proxy_read_timeout 10s;
With the above, I observed a 30s transfer start, and then it reached the backend service
With this commented out:
# lua_need_request_body on;
proxy_read_timeout 10s;
I observed a upstream timed out
in nginx, and transfer start getting cut short (file didn't finish uploading)
Their doc https://github.com/openresty/lua-nginx-module#lua_need_request_body indicates:
Determines whether to force the request body data to be read before running rewrite/access/content_by_lua* or not.
So they must be doing payload body processing before anything else takes over.
So the new question is, can Spring Cloud Gateway process uploading the file before any response-timeout settings kick in?
java
spring
netty
spring-cloud
spring-cloud-gateway
0 Answers
Your Answer