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: HttpClient SSL Connection Issue
Date Mon, 22 Feb 2016 20:17:32 GMT
On Mon, 2016-02-22 at 15:08 -0500, Murat Balkan wrote:
> Tom,
> It worked like a charm! Thank you very much!  It seems HTTPURLConnection
> and URL classes add a default "accept" header which is not implemented by
> Apache HttpClient.

'Accept' header as well as other content negotiation headers are
optional. HTTP agents do not have to implement content negotiation.

https://tools.ietf.org/html/rfc7231#section-5.3

Oleg


> Thanks again,
> Murat
> 
> On Mon, Feb 22, 2016 at 3:03 PM, Tim Jacomb [DATACOM] <timja@datacom.co.nz>
> wrote:
> 
> > Try adding an Accept Header, the server you are contacting appears to
> > reject all requests without one
> >
> > httpGet.addHeader("Accept",
> > "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
> >
> > Tim
> > ________________________________________
> > From: Murat Balkan <mrbalkan@gmail.com>
> > Sent: Tuesday, 23 February 2016 8:38 a.m.
> > To: HttpClient User Discussion
> > Subject: Re: HttpClient SSL Connection Issue
> >
> > Hi, Please find it below: The version does not matter. Whatever version I
> > tried failed. I even installed Java 8 to test. My current versions in the
> > built path are: httpclient4.5.1,httpcore4.4.3,httpmime 4.5.1, jna 4.1.0,
> > jna-platform4.1.0,httpclient-cache4.5.1
> >
> > SSLContext sslContext = SSLContexts.createDefault();
> > SSLConnectionSocketFactory sslConnectionFactory = new
> > SSLConnectionSocketFactory(sslContext,NoopHostnameVerifier.INSTANCE);
> > Registry<ConnectionSocketFactory> socketFactoryRegistry =
> > RegistryBuilder.<ConnectionSocketFactory>create()
> > .register("http", PlainConnectionSocketFactory.getSocketFactory())
> > .register("https", sslConnectionFactory)
> > .build();
> > PoolingHttpClientConnectionManager cm = new
> > PoolingHttpClientConnectionManager(socketFactoryRegistry);
> > cm.setDefaultMaxPerRoute(1);
> > CloseableHttpClient httpClient = HttpClientBuilder.create()
> > .disableContentCompression()
> > .disableAutomaticRetries()
> > .setUserAgent("User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:44.0)
> > Gecko/20100101 Firefox/44.0")
> > .build();
> > HttpGet httpGet = new HttpGet("https://so.n11.com");
> > httpClient.execute(httpGet);
> > System.out.println("I can never reach this point");
> >
> > On Mon, Feb 22, 2016 at 2:33 PM, Philippe Mouawad <
> > philippe.mouawad@gmail.com> wrote:
> >
> > > hi,
> > > Can you show your httpclient code and mention which versions you used for
> > > httpcore and httpclient and java exact version
> > >
> > > thx
> > >
> > > On Monday, February 22, 2016, Murat Balkan <mrbalkan@gmail.com> wrote:
> > >
> > > > I tried the following with URL class this time:
> > > >
> > > > URL my_url = new URL("https://so.n11.com");
> > > >         BufferedReader br = new BufferedReader(new
> > > > InputStreamReader(my_url.openStream()));
> > > >         String strTemp = "";
> > > >         while(null != (strTemp = br.readLine())){
> > > >         System.out.println(strTemp);
> > > >         }
> > > >
> > > > Even this works. So far URL, HttpURLConnection and Browsers are able to
> > > > fetch the page. Apache HttpClient cannot.
> > > > I also tried Fluent from the same package. It fails too.
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > On Mon, Feb 22, 2016 at 12:40 PM, Oleg Kalnichevski <olegk@apache.org
> > > > <javascript:;>>
> > > > wrote:
> > > >
> > > > > On Mon, 2016-02-22 at 11:27 -0500, Murat Balkan wrote:
> > > > > > Can you please suggest me how HttpClient can get the page like
> > > > > > HttpUrlConnection? or Google Chrome?
> > > > >
> > > > > Capture a session between a browser or HttpUrlConnection using
> > > Wireshark
> > > > > or browser plugin of your choosing. Configure HttpClient to generate
> > > > > identical messages. See what happens.
> > > > >
> > > > > > If I go to the site admin, wouldnt he say the site is totally
> > > > reachable?
> > > > > >
> > > > >
> > > > > The admin can say that Earth is flat for all I care, but their server
> > > > > drops connections without sending back a status code like all well
> > > > > behaved, spec complaint HTTP servers are supposed to do.
> > > > >
> > > > > Oleg
> > > > >
> > > > >
> > > > >
> > > > > > On Mon, Feb 22, 2016 at 11:22 AM, Oleg Kalnichevski <
> > > olegk@apache.org
> > > > <javascript:;>>
> > > > > > wrote:
> > > > > >
> > > > > > > On Mon, 2016-02-22 at 11:18 -0500, Murat Balkan wrote:
> > > > > > > > Hi Oleg,
> > > > > > > > I do not aggree, other Http libraries does not have
this
> > problem.
> > > > As
> > > > > I
> > > > > > > said
> > > > > > > > HttpUrlConnection gets the page, all types of browsers
can get
> > > the
> > > > > page.
> > > > > > > It
> > > > > > > > is clear that this is an error that is related with
the Apache
> > > > > Client.
> > > > > > > > Thnaks
> > > > > > > > Murat
> > > > > > >
> > > > > > > You are very welcome to disagree.
> > > > > > >
> > > > > > > Your own log clearly show that the problem has nothing
to do with
> > > SSL
> > > > > > > and is caused by peer connection reset.
> > > > > > >
> > > > > > > Oleg
> > > > > > >
> > > > > > >
> > > > > > > >
> > > > > > > > On Mon, Feb 22, 2016 at 11:14 AM, Oleg Kalnichevski
<
> > > > > olegk@apache.org <javascript:;>>
> > > > > > > > wrote:
> > > > > > > >
> > > > > > > > > On Mon, 2016-02-22 at 10:57 -0500, Murat Balkan
wrote:
> > > > > > > > > > I enabled the debug log and it seems the
connection is
> > > > > established .
> > > > > > > Any
> > > > > > > > > > ideas? Attaching below:
> > > > > > > > > >
> > > > > > > > > > 2016/02/22 10:49:45:146 EST [DEBUG]
> > > > > > > DefaultHttpClientConnectionOperator -
> > > > > > > > > > Connection established 142.133.240.86:34018<->
> > > > 176.41.133.12:443
> > > > > > > > > > 2016/02/22 10:49:45:146 EST [DEBUG] MainClientExec
-
> > > Executing
> > > > > > > request
> > > > > > > > > GET
> > > > > > > > > > / HTTP/1.1
> > > > > > > > > > 2016/02/22 10:49:45:146 EST [DEBUG] MainClientExec
- Target
> > > > auth
> > > > > > > state:
> > > > > > > > > > UNCHALLENGED
> > > > > > > > > > 2016/02/22 10:49:45:146 EST [DEBUG] MainClientExec
- Proxy
> > > auth
> > > > > > > state:
> > > > > > > > > > UNCHALLENGED
> > > > > > > > > > 2016/02/22 10:49:45:147 EST [DEBUG] headers
-
> > http-outgoing-3
> > > > >>
> > > > > GET
> > > > > > > /
> > > > > > > > > > HTTP/1.1
> > > > > > > > > > 2016/02/22 10:49:45:147 EST [DEBUG] headers
-
> > http-outgoing-3
> > > > >>
> > > > > > > Host:
> > > > > > > > > > so.n11.com
> > > > > > > > > > 2016/02/22 10:49:45:147 EST [DEBUG] headers
-
> > http-outgoing-3
> > > > >>
> > > > > > > > > > Connection: Keep-Alive
> > > > > > > > > > 2016/02/22 10:49:45:147 EST [DEBUG] headers
-
> > http-outgoing-3
> > > > >>
> > > > > > > > > > User-Agent: Apache-HttpClient/4.5.1 (Java/1.7.0_79)
> > > > > > > > > > 2016/02/22 10:49:45:148 EST [DEBUG] headers
-
> > http-outgoing-3
> > > > >>
> > > > > > > > > > Accept-Encoding: gzip,deflate
> > > > > > > > > > 2016/02/22 10:49:45:419 EST [DEBUG]
> > > > > > > DefaultManagedHttpClientConnection -
> > > > > > > > > > http-outgoing-3: Close connection
> > > > > > > > > > 2016/02/22 10:49:45:419 EST [DEBUG]
> > > > > > > DefaultManagedHttpClientConnection -
> > > > > > > > > > http-outgoing-3: Shutdown connection
> > > > > > > > > > 2016/02/22 10:49:45:419 EST [DEBUG] MainClientExec
-
> > > Connection
> > > > > > > discarded
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > > The connection is dropped by the server due to
an internal
> > > error
> > > > of
> > > > > > > some
> > > > > > > > > sort. You need to take it up with the server
admin.
> > > > > > > > >
> > > > > > > > > Oleg
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > ---------------------------------------------------------------------
> > > > > > > > > To unsubscribe, e-mail:
> > > > httpclient-users-unsubscribe@hc.apache.org <javascript:;>
> > > > > > > > > For additional commands, e-mail:
> > > > > httpclient-users-help@hc.apache.org <javascript:;>
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > ---------------------------------------------------------------------
> > > > > > > To unsubscribe, e-mail:
> > httpclient-users-unsubscribe@hc.apache.org
> > > > <javascript:;>
> > > > > > > For additional commands, e-mail:
> > > httpclient-users-help@hc.apache.org
> > > > <javascript:;>
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > > > <javascript:;>
> > > > > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> > > > <javascript:;>
> > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > Murat Balkan
> > > >
> > >
> > >
> > > --
> > > Cordialement.
> > > Philippe Mouawad.
> > >
> >
> >
> >
> > --
> > Murat Balkan
> > ---------------------------------------------------------------------
> > 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