spring-cloud / spring-cloud/spring-cloud-gateway
WebClient Request/Response bug?
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 4.9k
- Forks
- 3.5k
- Avg merge
- 20h 57m
- Merged PRs (30d)
- 8
Description
Describe the bug
Enabling WebClientHttpRoutingFilter & WebClientWriteResponseFilter leaves gateway client hanging. I can confirm that downstream HTTP calls works fine (200 OK with String Response), gateway logs also confirm 200 OK, but client is left hanging. Disabling WebClientHttpRoutingFilter & WebClientWriteResponseFilter beans (i.e., using default Netty routing & response handling) works just fine. We'd like to use a custom WebClient hence looking to get WebClientWriteResponseFilter working.
Appreciate any pointers. thanks
Sample
@Configuration
public class GatewayFilterConfig {
@Bean
public WebClient webClient() {
return WebClient.builder().build();
}
@Bean
public CustomWebClientRoutingFilter customWebClientRoutingFilter
(WebClient webClient, ObjectProvider<List<HttpHeadersFilter>> headersFilters) {
return new CustomWebClientRoutingFilter(webClient, headersFilters);
}
@Bean
public CustomWebClientResponseFilter customWebClientResponseFilter () {
return new CustomWebClientResponseFilter();
}
}
public class CustomWebClientRoutingFilter extends WebClientHttpRoutingFilter {
public CustomWebClientRoutingFilter(WebClient webClient, ObjectProvider<List<HttpHeadersFilter>> headersFiltersProvider) {
super(webClient, headersFiltersProvider);
}
@Override
public int getOrder() {
return Integer.MAX_VALUE - 1; //Run before the NettyRoutingFilter
}
}
public class CustomWebClientResponseFilter extends WebClientWriteResponseFilter {
@Override
public int getOrder() {
return Integer.MAX_VALUE;
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with WebClientHttpRoutingFilter and WebClientWriteResponseFilter, then reproduce the supplied GatewayFilterConfig and custom filter order. Compare the WebClient path with the default Netty routing and response handling; the issue is done when a downstream 200 response is delivered to the client instead of leaving it hanging.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring, spring-boot
- Domain
- api, backend, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100