读超时
RestClient
的读超时功能通过底层的HttpClient
来实现,可以分别支持 Client 级别 及 Request 级别。默认读超时为6000L
。Client级别读超时
Client级别的读超时将对该Client下的所有请求生效,具体配置方式如下:
final RestClient client = RestClient.create()
.readTimeout(3000L)
.build();
Request级别读超时
当Request设置了读超时,其数据将覆盖Client设置的读超时,具体配置方式如下:
final RestClient client = RestClient.ofDefault();
final String entity = client.get("http://127.0.0.1:8081/")
.readTimeout(3000L)
.execute()
.toCompletableFuture()
.get()
.bodyToEntity(String.class);
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.
Last modified April 22, 2022: add docs about traffic-split (34b84ce)