Setting request timeout for JAX-RS 2.0 Client API

Note: this is a new method available on JAX-RS 2.1

This is a very old post but the below code will work for both jersey and resteasy.

ClientBuilder clientBuilder = ClientBuilder.newBuilder();
clientBuilder.connectTimeout(10, TimeUnit.SECONDS);
clientBuilder.readTimeout(12, TimeUnit.SECONDS);
Client client = clientBuilder.build();

Leave a Comment