从 htmlunit WebClient 调用 getPage,禁用 JavaScript 并将 setTimeout 设置为 10000 永远等待
我在使用 Htmlunit 时遇到问题,我在调用 getpage 之前禁用了 JavaScript 并将超时设置为 10000,我预计超时后会出现异常,但 htmlunit 会永远等待。
经过一番搜索,我意识到 2009 年有人遇到了同样的问题(连接超时不起作用),他抱怨“连接超时不起作用”以及超时中的某些值不起作用,但直到 2011 年才得到任何答复。
有人这里询问抛出了什么异常,但我认为它并不总是抛出它。我无法从 Apache HttpClient 得到答案setTimeout 也可以。您可以在 终止或停止 HtmlUnit 中看到另一个人询问超时停止问题。
如果你尝试一下,你就会发现它有多么疯狂:
milisecReqTimeout = 10;
while(true)
{
_webclient.setTimeout(milisecReqTimeout);
milisecReqTimeout = milisecReqTimeout + 10;
_htmlpage = _webclient.getPage(url);
}
I'm having problems with Htmlunit, I disabled JavaScript and set timeout to 10000 before calling getpage, I expected an exception after timeout but htmlunit waits forever.
After some search I realized someone in 2009 had the same problem (Connection timeout not working), he was complaining about "Connection timeout not working" and about some values in timeout not working but until now in 2011 didn't get any answer.
Someone here was asking about what exception is thrown but I think it doesn't throw it always. I can't get an answer from Apache HttpClient setTimeout, either. You can see another person asking about stop in timeout in Terminate or Stop HtmlUnit.
You can see how crazy it is if you try:
milisecReqTimeout = 10;
while(true)
{
_webclient.setTimeout(milisecReqTimeout);
milisecReqTimeout = milisecReqTimeout + 10;
_htmlpage = _webclient.getPage(url);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
再见
Bye
我发现,使用 HttpUnit 1.6.2 设置这些
似乎可以解决问题。两者都是已弃用的方法。 :(
I found, with HttpUnit 1.6.2 setting these
Seemed to do the trick. Both are deprecated methods. :(