GetPage call from htmlunit WebClient with JavaScript disabled and setTimeout set to 10000, waiting forever

I have problems with Htmlunit, I turned off JavaScript and set a timeout to 10000 before calling getpage, I expected an exception after a timeout, but htmlunit waits forever.

After some searching, I realized that someone in 2009 had the same problem ( Connection timeout does not work ), he complained about โ€œConnection timeout does not workโ€ and some values โ€‹โ€‹in the timeout did not work, but before so far in 2011 has not received any response.

Someone here asked a question about which exception was thrown, but I think that he does not always throw it. I cannot get a response from Apache HttpClient setTimeout . You can see how another person asks about a timeout stop in Terminate or Stop HtmlUnit .

You can see how crazy he is if you try:

milisecReqTimeout = 10; while(true) { _webclient.setTimeout(milisecReqTimeout); milisecReqTimeout = milisecReqTimeout + 10; _htmlpage = _webclient.getPage(url); } 
+3
java timeout htmlunit
source share
2 answers

  _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; } }); 

code>

Bye

+3
source share

I found that HttpUnit 1.6.2 installed these

  final HttpClient client = new HttpClient(); final GetMethod method = new GetMethod(pUrl); client.setConnectionTimeout((int) timeout); client.setTimeout((int) timeout); final int statusCode = client.executeMethod(method); 

It seemed like a trick. Both are deprecated methods .: (

0
source share

All Articles