Questions tagged [spring-webclient]

WebClient makes it possible to perform reactive non-blocking HTTP requests in Spring applications. Use this tag for any questions involving its usage.

992 questions
4
votes
0 answers

How to handle "io.netty.channel.unix.Errors$NativeIoException: readAddress(..) failed: Connection reset by peer" in WebClient Springboot

I had 579,000 pending messages in my ActiveMQ, and I needed to publish these messages to a REST API. While doing so I was hitting the REST API at the rate of 3000 hits/second asynchronously. After some time I started getting the below mentioned…
4
votes
1 answer

Correct URL encoding of # Java WebClient

I'm tring to use this code to retrieve data from my API: Mono client = WebClient.builder() .baseUrl("https://localhost:8081/getPost/" + id) // or URLEncoder.encode(id, "UTF-8") .defaultHeaders(new…
Erry215
  • 326
  • 1
  • 4
  • 15
4
votes
2 answers

Handling connection errors in Spring reactive webclient

I have a spring webclient making http calls to an external service and backed by reactive circuit breaker factory (resilience4J impl). WebClient and circuit breaker behave as expected when the client establishes connection and fails on response (Any…
4
votes
1 answer

Correct dependencies to use when using WebClient with Spring MVC

I'm using Spring MVC to develop some controllers. I would like to write some scenario integration tests which will involve calling multiple controllers of my application. Normally I would have just used RestTemplate within these tests but the…
vab2048
  • 1,065
  • 8
  • 21
4
votes
1 answer

How to set TCP Keepalive in Reactor Netty HTTP client?

I saw that HttpClient.from(TcpClient.create().option(ChannelOption.SO_KEEPALIVE, true)) from method was deprecated. How currently am I supposed to set SO_KEEPALIVE using HttpClient.create()?
pixel
  • 24,905
  • 36
  • 149
  • 251
4
votes
1 answer

How to use Spring WebClient to make synchronous call?

Spring Framework in RestTemplate documentation has note: NOTE: As of 5.0 this class is in maintenance mode, with only minor requests for changes and bugs to be accepted going forward. Please, consider using the…
Openroad
  • 91
  • 1
  • 6
4
votes
1 answer

How can I save cookies between Spring WebClient requests?

I would like to use Spring Boot WebClient in my project to access a REST-API. The first request performs the login into the REST-API and receives a cookie as response. This cookie is used as an "API-Token" for all another requests. However, the…
Ben
  • 290
  • 2
  • 17
4
votes
1 answer

WebClient retrieving NULL as response body

I am invoking to a service with the following code: WebClient.create().get() .uri("http://www.somehost.es/api/products/1319/?ws_key=DC63ZTBVVQLN9MHQPQ9UMTL2DSW55C63") .retrieve() …
Mr.Eddart
  • 10,050
  • 13
  • 49
  • 77
4
votes
0 answers

Webclient 401 Unauthorized

I am using WebClient to access Endpoints, which are simple echo Endpoints, to test the connection. Everytime I am calling the WebClient get method I get a 401 error, but when I try to access the Endpoints with Swagger with the same credentials it…
4
votes
0 answers

In Java Webclient,, how to completely omitting a field when value is null in Mono serialization

I am on Java Spring Boot framework, trying to serialize a Java object using Mono for WebClient to use to send. I want to know whether I can completely remove a field when the value is found null. I don't seem to find a way to do that. Was trying…
samxiao
  • 2,587
  • 5
  • 38
  • 59
4
votes
3 answers

Return the complete response using Spring WebClient

I have the following code public ClientResponse doGet(HttpServletRequest request, URI uri) { return webClient.get() .uri(uri.toASCIIString()) .headers(headers -> headers.putAll(processRequest(request)) …
Philip John
  • 5,275
  • 10
  • 43
  • 68
4
votes
2 answers

Merge two api responses into one using Webclient - Webflux

I'm using WebFlux and WebClient and I need to consume two APIs and merge its responses. The first API receive type and document number and returns a list with one element that contains customer data (that's how it's defined). The second API receive…
4
votes
1 answer

Getting a lot of `PrematureCloseException : Connection prematurely closed BEFORE response`

We are receiving a lot of: reactor.core.ReactiveException: reactor.netty.http.client.PrematureCloseException: Connection prematurely closed BEFORE response at reactor.core.Exceptions.propagate(Exceptions.java:393) at…
igr
  • 10,199
  • 13
  • 65
  • 111
4
votes
0 answers

How to send object using BodyInserters.fromFormData

I'm currently asking you a question because I'm using a spring to write a test code that I don't know how to solve. The problem i'm trying to solve now is that i don't know how to send DTO to send Form Post Function using BodyInserters. The codes…
Liquid.Bear
  • 333
  • 6
  • 21
4
votes
2 answers

Webclient returning Optional.empty() on not found response

I'm trying to make WebClient return an Optional.empty() when I get a 404, not found, from the server. But instead I get a Optional with a User object with all properties set to null. What am I missing? @Override public Optional
heldt
  • 4,166
  • 7
  • 39
  • 67