연결 시간 초과를 구성
import io.netty.channel.ChannelOption;
HttpClient httpClient = HttpClient.create()
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10000);
WebClient webClient = WebClient.builder()
.clientConnector(new ReactorClientHttpConnector(httpClient))
.build();
읽기 또는 쓰기 시간 초과 구성
import io.netty.handler.timeout.ReadTimeoutHandler;
import io.netty.handler.timeout.WriteTimeoutHandler;
HttpClient httpClient = HttpClient.create()
.doOnConnected(conn -> conn
.addHandlerLast(new ReadTimeoutHandler(10))
.addHandlerLast(new WriteTimeoutHandler(10)));
// WebClient 생성...
특정 요청에 대한 응답 시간 초과를 구성
WebClient.create().get()
.uri("https://example.org/path")
.httpRequest(httpRequest -> {
HttpClientRequest reactorRequest = httpRequest.getNativeRequest();
reactorRequest.responseTimeout(Duration.ofSeconds(2));
})
.retrieve()
.bodyToMono(String.class);
'Spring > WebClient' 카테고리의 다른 글
[WebClient] Exchange (0) | 2024.03.28 |
---|---|
[WebClient] Retrieve (0) | 2024.03.28 |
[WebClient] Configuration Reactor Netty (0) | 2024.03.28 |
[WebClient] Configuration MaxInMemorySize (1) | 2024.03.28 |
[WebClient] Configuration Default (0) | 2024.03.28 |