commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adrian Sutton <>
Subject RE: HttpClient IO Exception on Solaris
Date Thu, 30 Jan 2003 23:21:57 GMT
Hi Francis,

This was a known bug that should have been fixed a while back.  The latest
alpha2 release should fix the issue, however it also changes the API to
allow for future improvements and to generally make life easier for people
new to HttpClient.  It shouldn't be too difficult to rework your code to use
the new API (a lot of backward compatibility was preserved) but you may
perfer to continue using the solution you are currently using.

For the record, the problem exists on all platforms not just Solaris, and
will occasionally show up as a HttpRecoverableException as well as an
IOException (a HttpException is always fatal).  Windows seems to have a
longer timeout for connections so the problem takes longer to show up but it
does occur eventually.

Adrian Sutton, Software Engineer
Ephox Corporation

-----Original Message-----
From: Vermeulen, Francis []
Sent: Friday, 31 January 2003 1:47 AM
To: ''
Subject: HttpClient IO Exception on Solaris


I'm having the following problem, that maybe someone has also encountered?

I've used HttpClient to develop a servlet that forwards an original URL to
another host, a sort of very basic proxy thus. The relevant source code
looks like this:

    private	HttpClient	makeHttpClient(HttpSession	session)
		// ServletContext	context	=

		String	targetPort	= _context.getInitParameter("port");
    	Integer	portNr	=	new	Integer(targetPort);
    	String	userName	=	_context.getInitParameter("user");
    	String	password	=
    	String	domain		=	_context.getInitParameter("domein");
    	HttpState	myState	=	new	HttpState();
    	NTCredentials	ntCredentials =	new	NTCredentials(

		myState.setCredentials("localhost:8080", ntCredentials);

		HttpClient	httpClient	=	new
    	log.debug("starting session on :" + _host + ":" + portNr);
    	httpClient.startSession(_host, portNr.intValue());
    	session.setAttribute("client", httpClient);
    	return	httpClient;    	

	private	void	ForwardRequest(HttpServletRequest
req,HttpServletResponse res, HttpMethod	method)	{

    	int	status	=	0;
    	int	retryCount	=	0;
    	boolean	success	=	false;
   		CopyRequestHeaders(req, method);

		HttpSession	session	=	req.getSession();    	
    	HttpClient	httpClient	=
    	//	If no httpClient in session, do it ourself, lifecycle events
    	//	are not supported then
    	if	(httpClient	==	null)	{
    		log.debug("No http client in session");
    		httpClient	=	makeHttpClient(session);

		while	((retryCount	<= 1)  && (success == false))
   			try {
				status	=
				success	=	true;

			} catch (IOException e) {
				log.error("IO exception occured on
				if	(retryCount	< 1)	{
					httpClient	=
					ReportError(res, e);
   		CopyResponseHeadersAndStatus(res, method);		

The retry stuff has been added because of the problem I have, i.e. on the
target Solaris platform, an IO exception "broken pipe"is thrown if the
requested page is reloaded in the browser after some time (my guess, after a
session timeout?). On the w2k development platform, I cannot reproduce this.
The redirect host is running an Apache web server. As you may see from the
code, the HttpClient is stored in the user's session and thus reused for the
duration of the session. All HTTP request headers and repsonse headers are
proxied, except for the connection headers. The servlet runs in an iPlanet
server engine on the Solaris machine in a JDK1.3.1 environment.

If anybody has a clue what might cause this problem on the Solaris machine,
that would be great help!


Ing. FRA Vermeulen
Senior J2EE Architect
ECM Solutions - Eindhoven
mobiel: +31 (0) 6 222 03 856

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message