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 we开发者_如何学Goll? What are the defaults for these?
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.
Do make sure to set the setReadTimeout as per the need of your application as setting connection timeout would be partial job done.
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);
精彩评论