简体   繁体   English

Restlet的客户端类中的超时如何工作?

[英]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: 可以尝试的几件事:

  1. Upgrade to Restlet 1.1.5, the latest version. 升级到最新版本的Restlet 1.1.5。 If this is a bug in the Client class, or in the connector you're using, it might have been fixed. 如果这是Client类或您使用的连接器中的错误,则可能已修复。 (If your app isn't going to production any time soon, you might want to try the latest preview release of 2.0.) (如果您的应用即将在短期内停止生产,则您可能需要尝试使用最新的预览版2.0。)
  2. Try using a different client connector. 尝试使用其他客户端连接器。 Especially if you're using the built-in connector — it's really only intended for casual development. 尤其是在使用内置连接器的情况下,它实际上仅适用于临时开发。
  3. Try asking on the mailing list. 尝试在邮件列表上询问。 The developers are very helpful and responsive there. 开发人员在这里非常乐于助人并且反应迅速。

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM