Return-Path: Delivered-To: apmail-jakarta-httpclient-user-archive@www.apache.org Received: (qmail 25909 invoked from network); 4 Dec 2006 14:05:54 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Dec 2006 14:05:54 -0000 Received: (qmail 19441 invoked by uid 500); 4 Dec 2006 14:06:02 -0000 Delivered-To: apmail-jakarta-httpclient-user-archive@jakarta.apache.org Received: (qmail 19429 invoked by uid 500); 4 Dec 2006 14:06:02 -0000 Mailing-List: contact httpclient-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: "HttpClient User Discussion" Reply-To: "HttpClient User Discussion" Delivered-To: mailing list httpclient-user@jakarta.apache.org Received: (qmail 19418 invoked by uid 99); 4 Dec 2006 14:06:02 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Dec 2006 06:06:02 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of juliusdavies@gmail.com designates 64.233.184.235 as permitted sender) Received: from [64.233.184.235] (HELO wr-out-0506.google.com) (64.233.184.235) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Dec 2006 06:05:51 -0800 Received: by wr-out-0506.google.com with SMTP id i4so1441952wra for ; Mon, 04 Dec 2006 06:05:31 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=eubDooL18L19rAClhanB2HvemLHXgfaLUJzl2RHdgtvE+Gg6CFdoRJ5+n21BY2YYaVdGX8FAEmiLFr6g4n+3MzmyH4RA4hZGhc3kB7iTDyMhJJMe7ufwqR7xUmvMCsoRrG7QzPTINSWOoMYUMs1lMLak7qR8Sjq7XmeyTlqxbd0= Received: by 10.90.113.18 with SMTP id l18mr7964069agc.1165241131005; Mon, 04 Dec 2006 06:05:31 -0800 (PST) Received: by 10.65.155.4 with HTTP; Mon, 4 Dec 2006 06:05:30 -0800 (PST) Message-ID: <598ad5b50612040605k226b3beeu4abaa46c8235da45@mail.gmail.com> Date: Mon, 4 Dec 2006 09:05:30 -0500 From: "Julius Davies" To: "HttpClient User Discussion" Subject: Re: SocketTimeoutException: Read timed out In-Reply-To: <2F2FA11BC93EB2498BAC4718363A9A55039C4F15@EX5.d.ethz.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <2F2FA11BC93EB2498BAC4718363A9A55039C4F15@EX5.d.ethz.ch> X-Virus-Checked: Checked by ClamAV on apache.org When you say it usually happens in the morning, after the first usage, that makes me suspect some kind of firewall rule (or VPN tunnel?) that closed down from inactivity, and then tries to quickly re-establish itself when the first TCP/IP packet comes through. Maybe you could implement some kind of repeating HEAD request (every 10 minutes?) just to keep all the wires warm? Steve Terrell's comments are also good. Probably better than mine. :-o yours, Julius On 12/4/06, Wittmann Armin (BI) wrote: > > > Hi > > I am using commons-httpclient in a 24x7 environment that > does send simple http-POST-requests with about 7 NameValuePairs. > Unfortunately I get sometimes the following error > java.net.SocketTimeoutException: Read timed out > (see stack trace below) > Worse is that this error cannot be reproduced in development > stage. It does occur mostly after a longer time of inactivity > or under high test load (=some 5 requests per second). > The average load in production is very low (e.g. 1 request per > 10 seconds). > > Fortunately the server recovers from this phase of malfunction > after some seconds and goes on working well. > Does anybody have the same effects or is it possible that I > am not programming API-conform. > > Here is the extract of my code inside the class CommonsHttpClient: > (variables with prefix '_' are field variables in this class initialized > in its > constructor [that reads out some properties from file]) > <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< > public String sendHttpRequest(int pGetOrPost, NameValuePair > pKeyValuePairs) throws LBSystemException { > > HttpConnectionManager connectionManager = new > SimpleHttpConnectionManager(); > connectionManager.setParams(_connectionManagerParams); > HttpClient client = new HttpClient(_clientParams, connectionManager); > client.setHostConfiguration(_hostConfiguration); > > HttpMethod method = null; > if (pGetOrPost == 0) { > method = new PostMethod(); > ((PostMethod) method).setRequestBody(pairs); > } else if (pGetOrPost == 1) { > method = new GetMethod(); > method.setQueryString(pairs); > } > > method.setPath(_contextPath); > method.setParams(_methodParams); > > int statusCode = -1; > boolean failed = false; > try { > statusCode = client.executeMethod(method); > } catch (Exception e) { > failed = true; > throw new MyException(p + "perform http.request failed.", e); > } finally { > try { > if (failed) { > method.abort(); > > try { > method.releaseConnection(); > } catch (Exception e) { > _log.warning(p + "releasing connection after > evaluating http.request failed (failed=" + failed + "):", e); > } > } > } catch (Exception e) { > _log.warning(p + "aborting http.POST after failure raised an > exception:", e); > } > client.setHttpConnectionManager(null); > client = null; > } > } > <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< > Notice: I do release the connection only in case of an exception! > > We checked with TCPDUMP on the receiving server. It does not not > receive anything in such a error case. This observation is not very > precise since we tried to estimate when it will occur (mostly in the > morning with the first usage). > > And now the stacktrace: > Caused by: java.net.SocketTimeoutException: Read timed out > at java.net.SocketInputStream.socketRead0(Native Method) > at java.net.SocketInputStream.read(Unknown Source) > at com.sun.net.ssl.internal.ssl.InputRecord.readFully(Unknown > Source) > at com.sun.net.ssl.internal.ssl.InputRecord.read(Unknown Source) > at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown > Source) > at > com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(Unknown > Source) > at com.sun.net.ssl.internal.ssl.AppInputStream.read(Unknown > Source) > at java.io.BufferedInputStream.fill(Unknown Source) > at java.io.BufferedInputStream.read(Unknown Source) > at > org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:77) > at > org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:105) > at > org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.jav > a:1115) > at > org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBa > se.java:1832) > at > org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase > .java:1590) > at > org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java > :995) > at > org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMe > thodDirector.java:397) > at > org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMetho > dDirector.java:170) > at > org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:3 > 96) > at > org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:3 > 24) > at > ch.ethz.id.bi.fw.common.util.http.CommonsHttpClient.sendHttpRequest(Comm > onsHttpClient.java:148) > ... 20 more > > --------------------------------------------------------------------- > To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: httpclient-user-help@jakarta.apache.org > > -- yours, Julius Davies 416-652-0183 http://juliusdavies.ca/ --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: httpclient-user-help@jakarta.apache.org