spring-cloud / spring-cloud/spring-cloud-gateway

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

Open
#3,692 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

waiting-for-triage
Dominant language
Java
Stars
4.9k
Forks
3.5k
Avg merge
20h 57m
Merged PRs (30d)
8

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with NettyRoutingFilter, especially getHttpClientMono and the response-timeout handling noted around line 190, then compare it with HttpClientProperties and HttpClientFactory. The fix is complete when the global connect-timeout property reaches the routing HttpClient while a route-specific connect-timeout can still override it.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring, spring-boot
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.