开发者

Java: Reasonable timeout period for URLConnection

开发者 https://www.devze.com 2023-01-21 14:06 出处:网络
By default the timeout for URLConnection is 0 which is unlimited.What is a reasonable value for XXXXX?

By default the timeout for URLConnection is 0 which is unlimited. What is a reasonable value for XXXXX?

U开发者_C百科RL url = ...
URLConnection uCon = url.openConnection();
uCon.setConnectTimeout(XXXXXX);


It entirely depends on your business logic. How long do you want your program to wait before it decides that it will just give up, rather than wait?

("Maybe if I just wait a little longer, then it'll connect!")


Anything is reasonable. Depending on the latency, on the target page. etc. Let's say 30 seconds.

0

精彩评论

暂无评论...
验证码 换一张
取 消