java - Call getPage from htmlunit WebClient with JavaScript disabled and setTimeout set to 10000 waits forever -
i'm having problems htmlunit, disabled javascript , set timeout 10000 before calling getpage, expected exception after timeout htmlunit waits forever.
after search realized in 2009 had same problem (connection timeout not working), complaining "connection timeout not working" , values in timeout not working until in 2011 didn't answer.
someone here asking exception thrown think doesn't throw always. can't answer apache httpclient settimeout, either. can see person asking stop in timeout in terminate or stop htmlunit.
you can see how crazy if try:
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 socket timeout (so_timeout) in milliseconds //be used when executing method. //a timeout value of 0 interpreted infinite timeout. //time read operation 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 // http connection http connection manager. // 0 means wait indefinitely. client.getparams().setparameter("http.connection-manager.timeout", _timeoutcliconnection); } client.getparams().setparameter("http.tcp.nodelay", true); return client; } });
bye
Comments
Post a Comment