Gustavo,
I have reviewed the code one more time. Everything appears sane (at
least to me). I know that SSL sockets sometimes behave really funny with
regards to socket read timeouts but I find it difficult to believe that
plain sockets would exhibit such a massive bug. Could you please try to
reproduce the problem using as little code as possible, preferably in a
form of JUnit test case?
Oleg
On Thu, 2004-12-16 at 11:50 -0600, Gustavo Hexsel wrote:
> I've had the same problem though. It might be a JDK bug. Running Sun's
> JDK 1.5 (build 1.5.0-b64). Happens on 1.4.2 too.
>
>
>
> The code is:
> GetMethod method = new GetMethod();
> ... set other config
> method.getParams().setSoTimeout(remainingTime);
> ... set host, port, prepare state
> int statusCode = client.executeMethod(hostConfig, method, state);
> ... verify if it is redirect, etc (manual redirects)
> while ((len = response.read(buffer)) > 0) {
> ... add the result to a stringbuffer for later multiline regex parsing
> }
>
>
>
> This is the log I get (timeout is about 10 seconds later, the default -
> not 150s as I set in the method!!!). Not that the timeout seems to be on
> "read", not "connect":
>
> ... the following are the defaults being set in init
> DEBUG| params.DefaultHttpParams - Set parameter http.connection.timeout =
> 20000
> DEBUG| params.DefaultHttpParams - Set parameter http.socket.timeout = 10000
> ... my preprocessors preparing a URL
> DEBUG| step.BaseStep - Preprocessor chain finished. URL to be called:
> http://dewey.chesterfield.k12.va.us/TLCScripts/interpac.dll?CrossField&FormI
> d=0&LimitsId=0&Config=all&ItemsPerPage=20&StartIndex=0&Term1Data=tree&Term1F
> ield=7&Operator1=0&Term2Data=&Term2Field=7&Operator2=0&Term3Data=&Term3Field
> =7&TermGrouping=0&ItemsPerPage=10&Branch=0
> DEBUG| params.DefaultHttpParams - Set parameter http.socket.timeout = 149938
> DEBUG| engine.HttpEngine - Http State = [ | | ]
> DEBUG| httpclient.HttpClient - enter
> HttpClient.executeMethod(HostConfiguration,HttpMethod,HttpState)
> DEBUG| httpclient.MultiThreadedHttpConnectionManager - enter
> HttpConnectionManager.getConnectionWithTimeout(HostConfiguration, long)
> DEBUG| httpclient.MultiThreadedHttpConnectionManager -
> HttpConnectionManager.getConnection: config =
> HostConfiguration[host=http://dewey.chesterfield.k12.va.us], timeout = 20000
> DEBUG| httpclient.MultiThreadedHttpConnectionManager - enter
> HttpConnectionManager.ConnectionPool.getHostPool(HostConfiguration)
> DEBUG| httpclient.MultiThreadedHttpConnectionManager - enter
> HttpConnectionManager.ConnectionPool.getHostPool(HostConfiguration)
> DEBUG| httpclient.MultiThreadedHttpConnectionManager - Allocating new
> connection,
> hostConfig=HostConfiguration[host=http://dewey.chesterfield.k12.va.us]
> DEBUG| httpclient.HttpMethodDirector - Attempt number 1 to process request
> DEBUG| httpclient.HttpConnection - enter HttpConnection.open()
> DEBUG| httpclient.HttpConnection - Open connection to
> dewey.chesterfield.k12.va.us:80
> DEBUG| httpclient.HttpMethodBase - enter HttpMethodBase.execute(HttpState,
> HttpConnection)
> DEBUG| httpclient.HttpMethodBase - enter
> HttpMethodBase.writeRequest(HttpState, HttpConnection)
> DEBUG| httpclient.HttpMethodBase - enter
> HttpMethodBase.writeRequestLine(HttpState, HttpConnection)
> DEBUG| httpclient.HttpMethodBase - enter
> HttpMethodBase.generateRequestLine(HttpConnection, String, String, String,
> String)
> DEBUG| wire.header - >> "GET
> /TLCScripts/interpac.dll?CrossField&FormId=0&LimitsId=0&Config=all&ItemsPerP
> age=20&StartIndex=0&Term1Data=tree&Term1Field=7&Operator1=0&Term2Data=&Term2
> Field=7&Operator2=0&Term3Data=&Term3Field=7&TermGrouping=0&ItemsPerPage=10&B
> ranch=0 HTTP/1.1[\r][\n]"
> DEBUG| httpclient.HttpConnection - enter HttpConnection.print(String)
> DEBUG| httpclient.HttpConnection - enter HttpConnection.write(byte[])
> DEBUG| httpclient.HttpConnection - enter HttpConnection.write(byte[], int,
> int)
> DEBUG| httpclient.HttpMethodBase - enter
> HttpMethodBase.writeRequestHeaders(HttpState,HttpConnection)
> DEBUG| httpclient.HttpMethodBase - enter
> HttpMethodBase.addRequestHeaders(HttpState, HttpConnection)
> DEBUG| httpclient.HttpMethodBase - enter
> HttpMethodBase.addUserAgentRequestHeaders(HttpState, HttpConnection)
> DEBUG| httpclient.HttpMethodBase - enter
> HttpMethodBase.addHostRequestHeader(HttpState, HttpConnection)
> DEBUG| httpclient.HttpMethodBase - Adding Host request header
> DEBUG| httpclient.HttpMethodBase - enter
> HttpMethodBase.addCookieRequestHeader(HttpState, HttpConnection)
> DEBUG| httpclient.HttpState - enter HttpState.getCookies()
> DEBUG| cookie.CookieSpec - enter CookieSpecBase.match(String, int, String,
> boolean, Cookie[])
> DEBUG| httpclient.HttpMethodBase - enter
> HttpMethodBase.addProxyConnectionHeader(HttpState, HttpConnection)
> DEBUG| wire.header - >> "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0;
> Windows NT 5.1)[\r][\n]"
> DEBUG| httpclient.HttpConnection - enter HttpConnection.print(String)
> DEBUG| httpclient.HttpConnection - enter HttpConnection.write(byte[])
> DEBUG| httpclient.HttpConnection - enter HttpConnection.write(byte[], int,
> int)
> DEBUG| wire.header - >> "Host: dewey.chesterfield.k12.va.us[\r][\n]"
> DEBUG| httpclient.HttpConnection - enter HttpConnection.print(String)
> DEBUG| httpclient.HttpConnection - enter HttpConnection.write(byte[])
> DEBUG| httpclient.HttpConnection - enter HttpConnection.write(byte[], int,
> int)
> DEBUG| httpclient.HttpConnection - enter HttpConnection.writeLine()
> DEBUG| httpclient.HttpConnection - enter HttpConnection.write(byte[])
> DEBUG| httpclient.HttpConnection - enter HttpConnection.write(byte[], int,
> int)
> DEBUG| httpclient.HttpConnection - enter
> HttpConnection.flushRequestOutputStream()
> DEBUG| wire.header - >> "[\r][\n]"
> DEBUG| httpclient.HttpConnection - enter
> HttpConnection.flushRequestOutputStream()
> DEBUG| httpclient.HttpMethodBase - enter
> HttpMethodBase.readResponse(HttpState, HttpConnection)
> DEBUG| httpclient.HttpMethodBase - enter
> HttpMethodBase.readStatusLine(HttpState, HttpConnection)
> DEBUG| httpclient.HttpConnection - enter HttpConnection.readLine()
> DEBUG| httpclient.HttpParser - enter HttpParser.readLine(InputStream,
> String)
> DEBUG| httpclient.HttpParser - enter HttpParser.readRawLine()
> DEBUG| httpclient.HttpMethodDirector - Closing the connection.
> DEBUG| httpclient.HttpConnection - enter HttpConnection.close()
> DEBUG| httpclient.HttpConnection - enter
> HttpConnection.closeSockedAndStreams()
> DEBUG| httpclient.HttpMethodDirector - Method retry handler returned false.
> Automatic recovery will not be attempted
> DEBUG| httpclient.HttpConnection - enter HttpConnection.releaseConnection()
> DEBUG| httpclient.HttpConnection - Releasing connection back to connection
> manager.
> DEBUG| httpclient.MultiThreadedHttpConnectionManager - enter
> HttpConnectionManager.releaseConnection(HttpConnection)
> DEBUG| httpclient.MultiThreadedHttpConnectionManager - Freeing connection,
> hostConfig=HostConfiguration[host=http://dewey.chesterfield.k12.va.us]
> DEBUG| httpclient.MultiThreadedHttpConnectionManager - enter
> HttpConnectionManager.ConnectionPool.getHostPool(HostConfiguration)
> DEBUG| util.IdleConnectionHandler - Adding connection at: 1103218848281
> DEBUG| httpclient.MultiThreadedHttpConnectionManager - Notifying no-one,
> there are no waiting threads
> DEBUG| engine.HttpEngine - Socket timeout on Http Method execution or stream
> read
> java.net.SocketTimeoutException: Read timed out
> at java.net.SocketInputStream.socketRead0(Native Method)
> at java.net.SocketInputStream.read(SocketInputStream.java:129)
> at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
> at java.io.BufferedInputStream.read(BufferedInputStream.java:235)
> at
> org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:76)
> at
> org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:104)
> at
> org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:11
> 12)
> at
> org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnect
> ionAdapter.readLine(MultiThreadedHttpConnectionManager.java:1379)
> at
> org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.j
> ava:1831)
> at
> org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.jav
> a:1594)
> at
> org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:999
> )
> at
> org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethod
> Director.java:382)
> at
> org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDir
> ector.java:168)
> at
> org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:393)
> at
> com.sagebrushcorp.oberon.searchengine.engine.JakartaHttpClientBridge.execute
> Method(JakartaHttpClientBridge.java:83)
> ...
>
>
>
> -----Original Message-----
> From: Oleg Kalnichevski [mailto:[EMAIL PROTECTED]
> Sent: December 16, 2004 9:14 AM
> To: HttpClient User Discussion
> Subject: Re: Timeout
>
>
> Ilya,
>
> I seriously doubt that this is the case. See for yourself
>
> http://jakarta.apache.org/commons/httpclient/3.0/xref/org/apache/commons/htt
> pclient/HttpMethodDirector.html#369
>
> Oleg
>
> On Thu, Dec 16, 2004 at 05:44:05PM +0200, Ilya Kharmatsky wrote:
> > I need to set the timeout for read/write for specific method.
> > If I'm using HttpClientParameters - everything works as expected,
> > after
> >
> > HttpClient client = new HttpClient();
> > client.getParams().setSoTimeout(1000);
> > GetMethod method = new GetMethod("http://www....");
> > client.executeMethod(method);
> >
> > ....
> >
> > In case, the server's response has been "too slow" - the
> > SocketTimeoutException
> > will be thrown.
> >
> > But, if I want to set same for single HttpMethod (by using its
> > HttpMethodParameter)
> > the timeout is ignored:
> >
> > HttpClient client = new HttpClient();
> > GetMethod method = new GetMethod("http://www....");
> > method.getParams().setSoTimeout(1000);
> > client.executeMethod(method);
> >
> > Any ideas?
> >
> > Thanks,
> > Ilya
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]