user256717
user256717

Reputation:

how to increase jersey WS timeout

How do I increase the jersey WS timeout? It is waiting on a call which takes around 2 minutes. It is timing out at WS layer. Do I have to increase client timeout as well? What are the defaults for these?

Upvotes: 20

Views: 17729

Answers (3)

MobileSam
MobileSam

Reputation: 818

You can use the two methods setConnectTimeOut and the setReadTimeout on your Client instance. The documentation specifies that the default values for both are null and thus the timeouts infinite.

Upvotes: 17

SANN3
SANN3

Reputation: 10099

We can use ClientProperties.CONNECT_TIMEOUT and ClientProperties.READ_TIMEOUT property.

Example :

ClientConfig configuration = new ClientConfig();
configuration.property(ClientProperties.CONNECT_TIMEOUT, 1000);
configuration.property(ClientProperties.READ_TIMEOUT, 1000);

Client client = ClientBuilder.newClient(configuration);

Upvotes: 3

Abhisar Swami
Abhisar Swami

Reputation: 135

Do make sure to set the setReadTimeout as per the need of your application as setting connection timeout would be partial job done.

Upvotes: 3

Related Questions