从禁用了JavaScript并且setTimeout设置为10000的htmlunit WebClient调用getPage永远等待 [英] Call getPage from htmlunit WebClient with JavaScript disabled and setTimeout set to 10000 waits forever
问题描述
我在使用Htmlunit时遇到问题,我在调用getpage之前禁用了JavaScript并将超时设置为10000,我希望超时后会出现异常,但htmlunit会一直等待.
经过一番搜索,我意识到2009年有人遇到了同样的问题(
有人此处正在询问引发了什么异常但我认为它不会总是抛出.我无法从 Apache HttpClient得到答案setTimeout .您可以在终止或停止HtmlUnit 中看到另一个询问超时停止的人. 如果尝试,您会发现它有多疯狂:
再见 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:
Bye 这篇关于从禁用了JavaScript并且setTimeout设置为10000的htmlunit WebClient调用getPage永远等待的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!milisecReqTimeout = 10;
while(true)
{
_webclient.setTimeout(milisecReqTimeout);
milisecReqTimeout = milisecReqTimeout + 10;
_htmlpage = _webclient.getPage(url);
}
milisecReqTimeout = 10;
while(true)
{
_webclient.setTimeout(milisecReqTimeout);
milisecReqTimeout = milisecReqTimeout + 10;
_htmlpage = _webclient.getPage(url);
}
_thewebclient.setWebConnection(new HttpWebConnection(_thewebclient) {
@Override
protected synchronized AbstractHttpClient getHttpClient() {
AbstractHttpClient client = super.getHttpClient();
if (_TimeoutCliSocket > 0) {
//Sets the socket timeout (SO_TIMEOUT) in milliseconds to
//be used when executing the method.
//A timeout value of zero is interpreted as an infinite timeout.
//Time that a read operation will block for, before generating
//an java.io.InterruptedIOException
client.getParams().setParameter("http.socket.timeout",
_TimeoutCliSocket);
}
if (_TimeoutCliConnection > 0) {
//The timeout in milliseconds used when retrieving an
// HTTP connection from the HTTP connection manager.
// Zero means to wait indefinitely.
client.getParams().setParameter("http.connection-manager.timeout",
_TimeoutCliConnection);
}
client.getParams().setParameter("http.tcp.nodelay", true);
return client;
}
});