spring-cloud-gateway icon indicating copy to clipboard operation
spring-cloud-gateway copied to clipboard

HttpClient instance in the NettyRoutingFilter does not use the properties provided there

Open genie137 opened this issue 11 months ago • 0 comments

Describe the bug Spring Cloud Gateway 4.2.0 JDK 21 Spring Boot 3.4.2

We were having some weird issues concerning connection timeouts. I was analzing some parts of the code and changing properties. While doing this I noticed that the property 'spring.cloud.gateway.httpclient.connectTimeout' never reaches the actual NettyRoutingFilter. The HttpClientProperties is being wired there, but when creating a httpClient for the acutal routing, the method getHttpClientMono uses the httpClient that is wired there also. Only overwriting the connect-timeout set directly on the route, not using the global property. Curous is that the response-timout property set in the same properties class, is used globally (NettyRoutingFilter L190).

This means that the global property is nog being usesd where it should. I do see that the properties are being used in the HttpClientFactory, but that factory is not being used to create the HttpClients in the NettyRoutingFilter.

So i think there are two solutions possible:

  1. Use the connect-timeout property from the HttpClientProperties and apply that to the httpclient created in the NettyRoutingFilter. And let it be overwritten if a route specifically sets it.
  2. Use the HttpClientFactory to create the httpClients in the NettyRouting filter.

Essentially my problem boils down to the fact that i want a global connect-timeout, and not set the property seperately on all routes individualy.

Sample Not applicable here.

genie137 avatar Feb 11 '25 11:02 genie137