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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 04:33:37  来源:igfitidea点击:

how to increase jersey WS timeout

javajersey

提问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 setConnectTimeOutand the setReadTimeouton your Clientinstance. The documentation specifies that the default values for both are nulland thus the timeouts infinite.

您可以在您的实例上使用这两种方法setConnectTimeOut和。文档指定两者的默认值都是无限的,因此超时是无限的。setReadTimeoutClientnull

回答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_TIMEOUTand ClientProperties.READ_TIMEOUTproperty.

我们可以使用ClientProperties.CONNECT_TIMEOUTClientProperties.READ_TIMEOUT财产。

Example :

例子 :

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

Client client = ClientBuilder.newClient(configuration);