[英]How does the timeout work in Restlet's client class?
Here's some code: 这是一些代码:
Client client = new Client(Protocol.HTTP);
client.setConnectTimeout(1); //milliseconds
Response response = client.post(url, paramRepresentation);
System.out.println("timed out");
What I would expect to happen is that it prints "timed out" before the resource has time to process. 我希望发生的是,它在资源有时间要处理之前打印“超时”。 Instead, nothing happens with the timeout and it doesn't print "timed out" until after the resource returns. 相反,超时不会发生任何事情,并且直到资源返回后才显示“超时”。 Even if I put a Thread.sleep(5000) at the resource that's handling the request, the entire sleep is performed, like the timeout did nothing. 即使我将Thread.sleep(5000)放在处理请求的资源上,也会执行整个睡眠,就像超时什么也不做一样。
Anyone have experience with this? 有人对此有经验吗? I'm using Restlet 1.1.1. 我正在使用Restlet 1.1.1。 Thanks. 谢谢。
A few things to try: 可以尝试的几件事:
Its open source and the code is pretty clean, I've looked at it before for other things. 它的开源和代码很干净,我之前已经看过其他内容。 Why not take a look? 为什么不看看?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.