hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: ThreadSafeClientConnManager and java.net.SocketException: Connection reset
Date Thu, 27 Aug 2009 18:53:37 GMT
droidin.net wrote:
> Hi Oleg,
> 
> It's ether nibble or I'm slow - I only got word "This" from your reply. If
> I'm doing these 2 lines wrong how should I do it?
> 
> Regards,
> 
> Bo
> 

Sorry about being so terse. You certainly do not want PlainSocketFactory 
to be registered as a socket factory for the HTTPS scheme. Use 
SSLSocketFactory instead.

Hope this helps

Oleg


> 
> olegk wrote:
>> On Wed, Aug 26, 2009 at 01:19:17PM -0700, droidin.net wrote:
>>> I define HttpClient in 2 different ways:
>>> 1. Plain vanilla: client = new DefaultHttpClient();
>>> 2. Thread safe:
>>>     private DefaultHttpClient getThreadSafeHttpClient() {
>>>         HttpParams params = new BasicHttpParams();
>>>         params.setParameter("http.useragent", USER_AGENT);
>>>         HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
>>>         HttpProtocolParams.setContentCharset(params, "UTF-8");
>>>         final SchemeRegistry registry = new SchemeRegistry();
>>>         registry.register(new Scheme("http",
>>> PlainSocketFactory.getSocketFactory(), 80));
>>>         registry.register(new Scheme("https",
>>> PlainSocketFactory.getSocketFactory(), 443));
>> This.
>>
>> Oleg
>>
>>
>>
>>>         final ThreadSafeClientConnManager manager = new
>>> ThreadSafeClientConnManager(params, registry);
>>>         return new DefaultHttpClient(manager, params);
>>>     }
>>>
>>> Then I run same JUnit test for both client types (simple GET request). #1
>>> always runs fine, #2 always fails with "java.net.SocketException:
>>> Connection
>>> reset". Debug/stacktrace output attached (fictitious site)
>>>
>>> I never get a chance to do anything with entity object since error is
>>> thrown
>>> at client#execute call
>>>
>>> http://www.nabble.com/file/p25157321/error.log error.log 
>>> -- 
>>> View this message in context:
>>> http://www.nabble.com/ThreadSafeClientConnManager-and-java.net.SocketException%3A-Connection-reset-tp25157321p25157321.html
>>> Sent from the HttpClient-User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>
>>
>>
> 


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


Mime
View raw message