hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Benussi" <mark_benu...@hotmail.com>
Subject https java.net.SocketException: Socket closed
Date Mon, 15 Nov 2004 19:50:37 GMT
I have searched the mail archive and the web for the best part of this 
afternoon so I am sorry if this has been asked before (Which I am sure it 
has).

I am simply trying to use the HttpClient to get https://www.verisign.com but 
am getting java.net.SocketException: Socket closed when attempting to 
execute the GetMethod.

I am doing the following:

Including the jsse1.0.3_03 libs.
Dynamically adding a provider - Security.addProvider(new 
com.sun.net.ssl.internal.ssl.Provider());

I assume the problem is own to my interaction with jsse.

Am running this in a WAS 5 Test environment but target environment is Tomcat 
5 (If that matters).

Code is the following.

String response = null;
GetMethod getMethod = null;
try {
	// Create a get method instance.
	getMethod = new PostMethod(uri);
	if (nameValuePairs != null && nameValuePairs.length > 0) {
		getMethod.setQueryString(nameValuePairs);
	}
	getMethod.setFollowRedirects(true);
	getMethod.setDoAuthentication(true);

	// Create an instance of HttpClient.
	HttpClient httpClient = new HttpClient();

	// Provide custom retry handler is necessary
	DefaultMethodRetryHandler retryhandler =
		new DefaultMethodRetryHandler();
	retryhandler.setRequestSentRetryEnabled(false);
	retryhandler.setRetryCount(3);
	getMethod.setMethodRetryHandler(retryhandler);

	// Execute the method.
	int statusCode = httpClient.executeMethod(httpMethod);
	if (statusCode != HttpStatus.SC_OK) {
		LogHelper.log(
			LogLevel.ERROR,
			"Method failed: " + httpMethod.getStatusLine());
	}

	// Read the response body.
	// Deal with the response.
	// Use caution: ensure correct character encoding and is not binary data
	response = httpMethod.getResponseBodyAsString();

} catch (URIException urie) {
	throw new ApplicationException(urie);
} catch (HttpException he) {
	throw new ApplicationException(he);
} catch (IOException ioe) {
	throw new ApplicationException(ioe);
} finally {
	// Release the connection.
	getMethod.releaseConnection();
}
// Process the response.

Your thoughts are appreciated.



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


Mime
View raw message