WebClient makes it possible to perform reactive non-blocking HTTP requests in Spring applications. Use this tag for any questions involving its usage.
Questions tagged [spring-webclient]
992 questions
3
votes
2 answers
Spring webclient - increase timeout duration after each retry
I am looking for a way to increase the duration of the timeout after successive retries on webclient calls.
For example, I want the first request to timeout after 50ms, the first retry will then timeout after 500ms, and a second and final retry to…

youngturtle
- 19
- 4
3
votes
0 answers
Difference between calling rest client asynchronously with webclient and @Async
I am planning to call an web rest endpoint asynchronously. Should i use webclient for all asynchronous invocation. OR can i use rest template and annotate the method with @Async. Will it still be invoked asynchronously.
Wats the differnce between…

VIJ
- 1,516
- 1
- 18
- 34
3
votes
1 answer
Spring WebClient with ParameterizedTypeReference doesn't work
I have a Spring Boot application and I'm using WebClient to make requests to an API that returns the following format {"results": {...}} where the object in the results field can be in multiple different formats. I created the following class to…

k.kolev
- 83
- 1
- 7
3
votes
2 answers
Spring WebClient Post body not getting passed
I am trying to use WebClient to Post a loan object to another microservice which saves this object in a DB. So theoretically the body (JSON loan object) should just be passed on to the API of the DB service. Somehow, I can't figure out how to…

Finn
- 33
- 1
- 6
3
votes
3 answers
How to set Base URI to Spring WebClient
I am trying to create a Spring WebClient to call REST API. For that, I wrote the following piece of code.
@Bean
public WebClient defaultWebClient() {
var tcpClient = TcpClient.create()
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS,…

keepmoving
- 1,813
- 8
- 34
- 74
3
votes
1 answer
Communication between Microservices: Spring cloud OpenFeign vs WebClient/RestTemplate
Any idea please about the best way to use for back to back communication ?
spring cloud OpenFeign or WebClient/RestTemplate ?
I think Feign client should be used when spring cloud gateway need to
communicate to other microservices, whereas…

Amir Choubani
- 829
- 2
- 14
- 28
3
votes
1 answer
How to specify a specfic port number for Spring WebTestClient
I have a locally running rest endpoint I am attempting to communicate with using Spring WebClient. As a first step for testing purposes, I am trying to use Spring WebTestClient. My local rest endpoint runs on a specific port (lets say 8068). My…

Timothy Clotworthy
- 1,960
- 2
- 19
- 42
3
votes
0 answers
How to log Request/Response body using WebClient filters - Spring WebFlux
I am using ExchangeFilterFunction to log requests and responses but I don't know how I can get the request/response body as a string or JSON format and log it.
The code looks as follows:
//logging method, url and headers, but the body of the request…

D.B
- 4,009
- 14
- 46
- 83
3
votes
0 answers
Significant failure rate while using WebClient to make non-blocking REST calls
I'm writing application that scans one of online shops and it's looking for new offers there. I'm using official REST API that allows up to 9000 requests per second (per clientId) and I've been asked to check around 350 different queries so right…

Weeedooo
- 501
- 8
- 25
3
votes
1 answer
Spring reactive Webclient timeout
I was trying to test the default timeout of Spring reactive Webclient .
For that purpose I created a rest endpoint that takes 10 hours to return a response.
I created a rest client using spring reactive Webclient. But I see that the spring Reactive…

Avinash Jethy
- 803
- 2
- 10
- 25
3
votes
2 answers
WebClient causes "java.lang.IllegalStateException: executor not accepting a task" in JUnit
I wanted to use reactive programming inside the JUnit testing framework to do system tests on a remote rest api.
I thus wrote:
@Test
void testWebClient() {
WebClient webClient = WebClient.builder()
.baseUrl(GITHUB_API_BASE_URL)
…

Guillaume Blanchet
- 461
- 5
- 11
3
votes
2 answers
Problems testing spring webflux Webclient with high load
I am trying to learn Spring Webflux comming from C# and NetCore, we have a very similar problem like this post, where a third party service provider has some response time problems.
But testing with spring-webclient is doubling the response time, I…

rekiem87
- 1,565
- 18
- 33
3
votes
1 answer
How to handle 500 error code using retrieve in webclient
I've read quite a few documentations and other stackoverflow questions regarding this matter but I can't seem to get my code working.
So essentially I have a WebClient making a POST request.
IF the response status is 200, then I make another call…

bootlover123
- 111
- 1
- 8
3
votes
2 answers
Spring Security 5 with oauth2 causing 'principalName cannot be empty' error
I'm trying to implement an oauth2 secured Spring Boot API with Spring Security 5. I want the API to be an oauth2 resource server and to be able to access external oauth2 resource servers using a WebClient, with client credentials grant.
I can…

Kasun
- 642
- 1
- 7
- 16
3
votes
1 answer
Can spring webclient be used with RESTful API which is not reactive based?
Is there any issues with using WebClient for fetching responses from multiple REST APIs which are not reactive based.

programmer
- 249
- 4
- 12