commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adrian Sutton <adrian.sut...@ephox.com>
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
www.ephox.com


-----Original Message-----
From: Vermeulen, Francis [mailto:Francis.Vermeulen@atosorigin.com]
Sent: Friday, 31 January 2003 1:47 AM
To: 'commons-user@jakarta.apache.org'
Subject: HttpClient IO Exception on Solaris


Hi,

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)
{
    	
    	log.debug("makeHttpClient");
    	
		// ServletContext	context	=
session.getServletContext();

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

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

		HttpClient	httpClient	=	new
HttpClient();    	
		
    	httpClient.setState(myState);
    	
    	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;
    	
    	log.debug("ForwardRequest");
    	
   		CopyRequestHeaders(req, method);

		HttpSession	session	=	req.getSession();    	
    	HttpClient	httpClient	=
(HttpClient)session.getAttribute("client");
    	
    	//	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	=
httpClient.executeMethod(method);
	
res.getOutputStream().print(method.getResponseBodyAsString());
				success	=	true;

			} catch (IOException e) {
				log.error("IO exception occured on
execute");
				if	(retryCount	< 1)	{
					httpClient	=
makeHttpClient(session);
					++retryCount;
				}
				else
				{
					ReportError(res, e);
					return;
				}
   			}
   		
		}
		
   		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!

Regards, 

============================================
Ing. FRA Vermeulen
Senior J2EE Architect
ECM Solutions - Eindhoven
mobiel: +31 (0) 6 222 03 856
e-mail: francis.vermeulen@atosorigin.com
============================================



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message