java 如何增加球衣WS超时
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4050176/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to increase jersey WS timeout
提问by Fakrudeen
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?
如何增加球衣 WS 超时?它正在等待大约需要 2 分钟的呼叫。它在 WS 层超时。我是否也必须增加客户端超时?这些的默认值是什么?
采纳答案by MobileSam
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.
您可以在您的实例上使用这两种方法setConnectTimeOut
和。文档指定两者的默认值都是无限的,因此超时是无限的。setReadTimeout
Client
null
回答by Abhisar Swami
Do make sure to set the setReadTimeoutas per the need of your application as setting connection timeout would be partial job done.
请确保根据您的应用程序的需要设置setReadTimeout,因为设置连接超时将完成部分工作。
回答by SANN3
We can use ClientProperties.CONNECT_TIMEOUT
and ClientProperties.READ_TIMEOUT
property.
我们可以使用ClientProperties.CONNECT_TIMEOUT
和ClientProperties.READ_TIMEOUT
财产。
Example :
例子 :
ClientConfig configuration = new ClientConfig();
configuration.property(ClientProperties.CONNECT_TIMEOUT, 1000);
configuration.property(ClientProperties.READ_TIMEOUT, 1000);
Client client = ClientBuilder.newClient(configuration);