Web服务连接超时和请求超时之间的差异 [英] Difference between web service connection timeout and request timeout
问题描述
WebClientTestService service = new WebClientTestService() ;
int connectionTimeOutInMs = 5000;
Map<String,Object> context=((BindingProvider)service).getRequestContext();
context.put("com.sun.xml.internal.ws.connect.timeout", connectionTimeOutInMs);
context.put("com.sun.xml.internal.ws.request.timeout", connectionTimeOutInMs);
context.put("com.sun.xml.ws.request.timeout", connectionTimeOutInMs);
context.put("com.sun.xml.ws.connect.timeout", connectionTimeOutInMs);
请分享主要在连接超时和请求超时方面的差异。
Please share the differences mainly in connect timeout and request timeout.
我需要知道这些参数值的推荐值。
I need to know the recommended values for these parameter values.
设置超时值的标准是什么?
What are the criteria for setting timeout value ?
推荐答案
请分享主要在连接超时和请求超时方面的差异。
Please share the differences mainly in connect timeout and request timeout.
我需要知道这些参数值的推荐值。
I need to know the recommended values for these parameter values.
- 连接超时(10s-30s) :等待多长时间进行初始连接,例如如果服务当前不可用。
- 套接字超时(10s-20s):如果服务在发送数据后停止响应,则等待多长时间。
- 请求超时(30s-300s):等待整个请求完成的时间。
什么设置超时值的标准是什么?
What are the criteria for setting timeout value ?
如果1-2分钟后没有发生任何事情,那将取决于网络用户是否会感到不耐烦可以允许后端请求运行更长时间。
It depends a web user will get impatient if nothing has happened after 1-2 minutes, however a back end request could be allowed to run longer.
还要考虑在请求完成(或超时)之前不释放服务器资源 - 因此,如果您有太多请求和超时,您的服务器可能会耗尽资源并且无法为进一步的请求提供服务。
Also consider server resources are not released until request completes (or times out) - so if you have too many requests and long timeouts your server could run out of resources and be unable to service further requests.
请求超时应该设置为大于请求完成的预期时间的值,可能有一些空间允许偶尔降低性能重载。
request timeout should be set to a value greater then the expected time for the request to complete, perhaps with some room to allow occasionally slower performance under heavy loads.
连接/套接字超时通常设置得更低,因为通常表示服务器问题,等待另外10-15秒通常无法解决。
connect/socket timeouts are often set lower as normally indicate a server problem where waiting another 10-15s usually won't resolve.
这篇关于Web服务连接超时和请求超时之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!