What is the meaning and difference between `spring. cloud. gateway.httpclient` and `spring. cloud. gateway.httpserver` ?
spring:
cloud:
gateway:
httpserver:
# org.springframework.cloud.gateway.config.GatewayAutoConfiguration.NettyConfiguration
wiretap: true
# org.springframework.cloud.gateway.config.HttpClientProperties
httpclient:
wiretap: true
connectTimeout: 20000
response-timeout: 10s
pool:
type: fixed
max-connections: 500
maxLifeTime: 5000
acquire-timeout: 20000
max-idle-time: 10000
discovery:
filters:
default-filters:
- name: Retry
args:
retries: 5
statuses:
- BAD_GATEWAY
- GATEWAY_TIMEOUT
version
- spring-cloud-gateway: 2.2.9.RELEASE
- spring-boot: 2.3.12.RELEASE
- reactor-netty: 0.9.20.RELEASE
- Sorry, I am a freshman of this excellent projects.My situation : After repeatedly reading the source code and network articles of the project, I still have the following questions about the management of internal and external HTTP Connections in the SCG gateway. Can you answer them for me?
-
Q1 What is the meaning and difference between
spring. cloud. gateway.httpclientandspring. cloud. gateway.httpserver?andspring. cloud. gateway.httpclient.poolandspring. cloud. gateway.httpserver? -
Q2 Based on Q1's question and the following call relationship, what is the HTTP connection configuration (such as connection Timeout) for the corresponding SCG? How to explain it?
SCG External Application --call--> SCG --call--> SCG Proxied Internal Microservices Relationship 1: SCG External Application --call--> SCG Relationship 2: SCG --call--> SCG Proxied Internal Microservices
- Q3 Based on Q2, how should the timeout duration be configured for SCG gateway external calls to SCG?
- I think these problems may also be encountered by other beginners, so I suggest that after answering these questions, developers can reflect them in the corresponding source code comments and explanatory documents.
Thanks~
Q1. The spring.cloud.gateway.httpclient component is responsible for handling outgoing HTTP requests from the gateway to other services. It provides a customizable HTTP client implementation that allows you to configure things like connection timeouts, maximum connections per route, and SSL settings. This component is used when the gateway is acting as a client to other services.
The 'spring.cloud.gateway.httpserver' component, on the other hand, is responsible for handling incoming HTTP requests from clients and routing them to the appropriate backend services. It provides a customizable HTTP server implementation that allows you to configure things like server ports, SSL settings, and request/response filters. This component is used when the gateway is acting as a server to clients.
In summary, the 'spring.cloud.gateway.httpclient' component is used for making outgoing requests, while the 'spring.cloud.gateway.httpserver' component is used for handling incoming requests.
Q2. To configure the connection timeout for 'spring.cloud.gateway.httpclient', you can set the property 'spring.cloud.gateway.httpclient.connect-timeout' to the desired value in milliseconds.
Q3. As explained in Q2 you can try this option or try to use the next example if you want to custom connection timeout per route:
- id: per_route_timeouts
uri: https://example.org
predicates:
- name: Path
args:
pattern: /delay/{timeout}
metadata:
response-timeout: 200
connect-timeout: 200
I hope my answer will be helpful. @Johnny-ZTSD
Closing due to age of the question. If you would like us to look at this issue, please comment and we will look at re-opening the issue.