SSL trouble with wildcards and certs in 4.4 beta1

2015-01-06 Thread Dan Quaroni
This used to work in 4.3...  I've tried setting other HostNameVerifiers
(which seem to be all deprecated now in 4.4) but that also hasn't helped.
The Default verifier is rejecting a cert with a wilcard in it:

javax.net.ssl.SSLPeerUnverifiedException: Host name 'us8.api.mailchimp.com'
does not match the certificate subject provided by the peer (CN=*.
api.mailchimp.com, OU=Rocket Science Group, O=ROCKET SCIENCE GROUP,
L=Atlanta, ST=GA, C=US)



-- 

*Daniel Quaroni*
Principal Software Architect
P: 781.810.2743
q...@invoke.com
www.invoke.com
See a Demo here 


Re: SSL trouble with wildcards and certs in 4.4 beta1

2015-01-08 Thread Dan Quaroni
The problem doesn't reproduce with the trunk, so I suppose from my
perspective that's mission accomplished.

Thanks.

On Wed, Jan 7, 2015 at 4:33 AM, Oleg Kalnichevski  wrote:

> On Tue, 2015-01-06 at 17:08 -0500, Dan Quaroni wrote:
> > This used to work in 4.3...  I've tried setting other HostNameVerifiers
> > (which seem to be all deprecated now in 4.4) but that also hasn't helped.
> > The Default verifier is rejecting a cert with a wilcard in it:
> >
> > javax.net.ssl.SSLPeerUnverifiedException: Host name '
> us8.api.mailchimp.com'
> > does not match the certificate subject provided by the peer (CN=*.
> > api.mailchimp.com, OU=Rocket Science Group, O=ROCKET SCIENCE GROUP,
> > L=Atlanta, ST=GA, C=US)
> >
> >
> >
>
> I am not sure this issue is necessarily caused by wildcard in the
> subject's CN. Could you please upgrade to the latest snapshot from
> HttpClient trunk [1], execute the request with context logging on [2]
> and post the resultant log to this list?
>
> Oleg
>
> [1] https://github.com/apache/httpclient/tree/trunk
> [2] http://hc.apache.org/httpcomponents-client-4.3.x/logging.html
>
>
>
> -
> To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
> For additional commands, e-mail: httpclient-users-h...@hc.apache.org
>
>


-- 

*Daniel Quaroni*
Principal Software Architect
P: 781.810.2743
q...@invoke.com
www.invoke.com
See a Demo here <http://www.invoke.com/platform/demo>


Re: How to handle session using Httpclient or FirefoxDriver using Java

2015-03-10 Thread Dan Quaroni
I haven't tried the link you supplied, but I'm guessing that us.vwr.com
requires a session to be in place before it allows a search to be
executed.  You should first make a request to their home page or store page
or wherever the session gets initiated and put the session cookie on the
request to the link you've provided.

On Tue, Mar 10, 2015 at 5:40 AM, gdrsantosh  wrote:

> Hi,I have tried the following code to get the page content but,it results
> in
> Session Expired.I want to know the solution
> for this problem.
>
>   HttpGet httpGet = new
> HttpGet("
> http://us.vwr.com/store/search/searchResultList.jsp?_DARGS=/store/search/includes/categorySearchResultGrid.jsp.1_AF&_dynSessConf=8835674528907442989&sfh_showProducts=submit&catName=Batteries&_D%3Asfh_showProducts=+&catId=542671%2C
> ");
>HttpClient httpclient = new DefaultHttpClient();
>HttpResponse response = httpclient.execute(httpGet);
>HttpEntity entity =response.getEntity();
>String thirdPartyPageContent=EntityUtils.toString(entity);
>System.out.println(thirdPartyPageContent);
>
>
>
> --
> View this message in context:
> http://httpcomponents.10934.n7.nabble.com/How-to-handle-session-using-Httpclient-or-FirefoxDriver-using-Java-tp25842.html
> Sent from the HttpClient-User mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
> For additional commands, e-mail: httpclient-users-h...@hc.apache.org
>
>


-- 

*Daniel Quaroni*
Principal Software Architect
P: 781.810.2743
q...@invoke.com
www.invoke.com
See a Demo here 


Re: HTTP Error 400. The request hostname is invalid.

2015-03-22 Thread Dan Quaroni
A 400 with that error message is just bizarre.  But to cover all your
bases, have you tried pinging (or telnetting to port 80) the server from
the iSeries machine?

Over the years I've tried IBM's JDK and have always found that it fails to
function properly in this edge case or that, but these types of edge cases
come up frequently that IMHO it's not production ready.  Can you switch to
Oracle's JDK?



On Sun, Mar 22, 2015 at 5:13 PM, Bill Gottlieb 
wrote:

> I use HttpClient 4.4 to connect to an IIS https REST web service.  When I
> test from my PC everything works fine, returning data from the server
> without issue.  I load the same code onto my IBM iSeries and receive the
> following error "HTTP Error 400 - The request hostname is invalid.".  Both
> are using JDK 1.6.  The PC uses Oracle's and the iSeries uses IBM's JDK.
>
> The IIS folks have tried to change things on their end, to no avail.  I've
> tried with both of the following from my end, thinking the second would
> work no matter what:
>
>   CloseableHttpClient browser = HttpClientBuilder.create().build();
>   CloseableHttpClient browser =
> HttpClients.custom().setSSLHostnameVerifier(new
> NoopHostnameVerifier()).build();
>
> Does anybody have any ideas that could help me solve this problem?  Thanks!
>



-- 

*Daniel Quaroni*
Principal Software Architect
P: 781.810.2743
q...@invoke.com
www.invoke.com
See a Demo here 


Re: PoolingHttpClientConnectionManager SSL Handshake exception

2015-09-08 Thread Dan Quaroni
HttpClient did get more picky about certs.

On Tue, Sep 8, 2015 at 4:31 AM, Bhuvaneswari Anandhan <
bhuvaneswari.anand...@oracle.com> wrote:

> Hi ,
>
>
>
> Recently we have done a Apache http component migration from 3.1 to 4.4.1.
>
>
>
> We have changed the connection manager implementation from
> MultiThreadedHttpConnectionManager (3.1 implementation) to
> PoolingHttpClientConnectionManager (apache httpclient 4.4.1).
>
>
>
>
>
> Now we are getting SSL socket exception when we are trying to request
> using the connection.
>
>
>
> Exception trace:
>
> [9/8/15 12:04:27:192 IST] 0064 SystemErr R
> javax.net.ssl.SSLHandshakeException: com.ibm.jsse2.util.g: PKIX path
> building failed: java.security.cert.CertPathBuilderException:
> PKIXCertPathBuilderImpl could not build a valid CertPath.; internal cause
> is:
>
> java.security.cert.CertPathValidatorException: The
> certificate issued by CN=mumgo3206.in.oracle.com, OU=Root Certificate,
> OU=RSAppSrvCell1, OU=RSAppSrvNode1, O=IBM, C=US is not trusted; internal
> cause is:
>
> java.security.cert.CertPathValidatorException: Certificate
> chaining error
>
> [9/8/15 12:04:27:193 IST] 0064 SystemErr R at
> com.ibm.jsse2.n.a(n.java:28)
>
> [9/8/15 12:04:27:193 IST] 0064 SystemErr R at
> com.ibm.jsse2.tc.a(tc.java:251)
>
> [9/8/15 12:04:27:193 IST] 0064 SystemErr R at
> com.ibm.jsse2.gb.a(gb.java:251)
>
> [9/8/15 12:04:27:194 IST] 0064 SystemErr R at
> com.ibm.jsse2.gb.a(gb.java:228)
>
> [9/8/15 12:04:27:194 IST] 0064 SystemErr R at
> com.ibm.jsse2.hb.a(hb.java:279)
>
> [9/8/15 12:04:27:194 IST] 0064 SystemErr R at
> com.ibm.jsse2.hb.a(hb.java:292)
>
> [9/8/15 12:04:27:194 IST] 0064 SystemErr R at
> com.ibm.jsse2.gb.n(gb.java:71)
>
> [9/8/15 12:04:27:194 IST] 0064 SystemErr R at
> com.ibm.jsse2.gb.a(gb.java:324)
>
> [9/8/15 12:04:27:194 IST] 0064 SystemErr R at
> com.ibm.jsse2.tc.a(tc.java:559)
>
> [9/8/15 12:04:27:195 IST] 0064 SystemErr R at
> com.ibm.jsse2.tc.g(tc.java:25)
>
> [9/8/15 12:04:27:195 IST] 0064 SystemErr R at
> com.ibm.jsse2.tc.a(tc.java:582)
>
> [9/8/15 12:04:27:195 IST] 0064 SystemErr R at
> com.ibm.jsse2.tc.startHandshake(tc.java:652)
>
> [9/8/15 12:04:27:195 IST] 0064 SystemErr R at
> org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:394)
>
> [9/8/15 12:04:27:195 IST] 0064 SystemErr R at
> org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:353)
>
> [9/8/15 12:04:27:195 IST] 0064 SystemErr R at
> org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:134)
>
> [9/8/15 12:04:27:195 IST] 0064 SystemErr R at
> org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
>
> [9/8/15 12:04:27:196 IST] 0064 SystemErr R at
> org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
>
> [9/8/15 12:04:27:196 IST] 0064 SystemErr R at
> org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
>
> [9/8/15 12:04:27:196 IST] 0064 SystemErr R at
> org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
>
> [9/8/15 12:04:27:196 IST] 0064 SystemErr R at
> org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
>
> [9/8/15 12:04:27:196 IST] 0064 SystemErr R at
> org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
>
> [9/8/15 12:04:27:196 IST] 0064 SystemErr R at
> org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
>
> [9/8/15 12:04:27:197 IST] 0064 SystemErr R at
> org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:117)
>
> [9/8/15 12:04:27:197 IST] 0064 SystemErr R at
> org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
>
> [9/8/15 12:04:27:197 IST] 0064 SystemErr R at
> com.citi.cpb.emea.revelation.proxy.ProxyServlet.sendApplicationRequest(ProxyServlet.java:392)
>
> [9/8/15 12:04:27:197 IST] 0064 SystemErr R at
> com.citi.cpb.emea.revelation.proxy.ProxyServlet.doGet(ProxyServlet.java:130)
>
> [9/8/15 12:04:27:197 IST] 0064 SystemErr R at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:575)
>
> [9/8/15 12:04:27:197 IST] 0064 SystemErr R at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
>
> [9/8/15 12:04:27:198 IST] 0064 SystemErr R

Re: HttpClientBuilder Memory Leak

2016-02-02 Thread Dan Quaroni
What version of HttpClient are you using?  I cut the sleep down to 1ms and
have had it running for 25 minutes and am not observing any such memory
leak.

On Tue, Feb 2, 2016 at 3:21 PM, Oleg Kalnichevski  wrote:

> On Tue, 2016-02-02 at 21:16 +0100, David Skalka wrote:
> > what is it "own data" ?
> >
>
> https://drive.google.com/open?id=0B8cERbS5JTTtZkVpWmhVWS11UkU
>
> Oleg
>
>
> > 2016-02-02 21:11 GMT+01:00 Oleg Kalnichevski :
> >
> > > On Tue, 2016-02-02 at 20:58 +0100, David Skalka wrote:
> > > > it is simple test application with one while. here is whole source
> code:
> > > >
> > >
> > > Have you looked at your own data?
> > >
> > > Oleg
> > >
> > > >
> > > > import java.io.IOException;
> > > >
> > > > import org.apache.http.impl.client.CloseableHttpClient;
> > > > import org.apache.http.impl.client.HttpClientBuilder;
> > > >
> > > >
> > > > public class Program {
> > > >
> > > > public static void main(String[] args) throws IOException,
> > > > InterruptedException {
> > > >
> > > > while(true){
> > > > CloseableHttpClient httpclient =
> > > > HttpClientBuilder.create().build();
> > > > httpclient.close();
> > > > Thread.sleep(5);
> > > > }
> > > >
> > > >
> > > > }
> > > >
> > > > }
> > > >
> > > >
> > > > 2016-02-02 20:51 GMT+01:00 Oleg Kalnichevski :
> > > >
> > > > > On Tue, 2016-02-02 at 20:42 +0100, David Skalka wrote:
> > > > > > sorry i dont understand you. What do you mean by "what does this
> all
> > > tell
> > > > > > you" ?
> > > > > >
> > > > >
> > > > > Have you taken even a cursory look at your own data?
> > > > >
> > > > > What makes you think there is a leak in HttpClient?
> > > > >
> > > > > Oleg
> > > > >
> > > > > > 2016-02-02 20:21 GMT+01:00 Oleg Kalnichevski :
> > > > > >
> > > > > > > On Tue, 2016-02-02 at 19:30 +0100, David Skalka wrote:
> > > > > > > > Here is long running snapshot with types
> > > > > > > >
> > > > > > > >
> https://drive.google.com/open?id=0B8cERbS5JTTtZkVpWmhVWS11UkU
> > > > > > >
> > > > > > > And what does this all tell you?
> > > > > > >
> > > > > > > Oleg
> > > > > > >
> > > > > > > >
> > > > > > > > 2016-02-02 17:22 GMT+01:00 Gary Gregory <
> garydgreg...@gmail.com
> > > >:
> > > > > > > >
> > > > > > > > > Can you look and see what kind of objects are retained?
> > > > > > > > >
> > > > > > > > > Gary
> > > > > > > > > On Feb 2, 2016 2:33 AM, "David Skalka" <
> david.ska...@gmail.com
> > > >
> > > > > wrote:
> > > > > > > > >
> > > > > > > > > > Why this code causes a memory leak?
> > > > > > > > > >
> > > > > > > > > > code:
> > > > > > > > > >
> > > > > > > > > > *while(true){*
> > > > > > > > > > * CloseableHttpClient httpclient =
> > > > > > > HttpClientBuilder.create().build();*
> > > > > > > > > > * httpclient.close();*
> > > > > > > > > > * Thread.sleep(5);*
> > > > > > > > > > * }*
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Here is a graph of memory allocation:
> > > > > > > > > >
> > > > > > > > > >
> > > > > https://drive.google.com/file/d/0B8cERbS5JTTtMnUyVXJNZDRFbHM/view
> > > > > > > > > >
> > > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > -
> > > > > > > To unsubscribe, e-mail:
> httpclient-users-unsubscr...@hc.apache.org
> > > > > > > For additional commands, e-mail:
> > > httpclient-users-h...@hc.apache.org
> > > > > > >
> > > > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> -
> > > > > To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
> > > > > For additional commands, e-mail:
> httpclient-users-h...@hc.apache.org
> > > > >
> > > > >
> > >
> > >
> > >
> > > -
> > > To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
> > > For additional commands, e-mail: httpclient-users-h...@hc.apache.org
> > >
> > >
>
>
>
> -
> To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
> For additional commands, e-mail: httpclient-users-h...@hc.apache.org
>
>


-- 

*Daniel Quaroni*
Principal Software Architect
P: 781.810.2743
q...@invoke.com
www.invoke.com
See a Demo here 


Re: HttpClientBuilder Memory Leak

2016-02-02 Thread Dan Quaroni
Ah.  I'm using 4.5.  Perhaps it's no longer an issue.

On Tue, Feb 2, 2016 at 3:34 PM, David Skalka  wrote:

> 4.4.1
>
> 2016-02-02 21:29 GMT+01:00 Dan Quaroni :
>
> > What version of HttpClient are you using?  I cut the sleep down to 1ms
> and
> > have had it running for 25 minutes and am not observing any such memory
> > leak.
> >
> > On Tue, Feb 2, 2016 at 3:21 PM, Oleg Kalnichevski 
> > wrote:
> >
> > > On Tue, 2016-02-02 at 21:16 +0100, David Skalka wrote:
> > > > what is it "own data" ?
> > > >
> > >
> > > https://drive.google.com/open?id=0B8cERbS5JTTtZkVpWmhVWS11UkU
> > >
> > > Oleg
> > >
> > >
> > > > 2016-02-02 21:11 GMT+01:00 Oleg Kalnichevski :
> > > >
> > > > > On Tue, 2016-02-02 at 20:58 +0100, David Skalka wrote:
> > > > > > it is simple test application with one while. here is whole
> source
> > > code:
> > > > > >
> > > > >
> > > > > Have you looked at your own data?
> > > > >
> > > > > Oleg
> > > > >
> > > > > >
> > > > > > import java.io.IOException;
> > > > > >
> > > > > > import org.apache.http.impl.client.CloseableHttpClient;
> > > > > > import org.apache.http.impl.client.HttpClientBuilder;
> > > > > >
> > > > > >
> > > > > > public class Program {
> > > > > >
> > > > > > public static void main(String[] args) throws IOException,
> > > > > > InterruptedException {
> > > > > >
> > > > > > while(true){
> > > > > > CloseableHttpClient httpclient =
> > > > > > HttpClientBuilder.create().build();
> > > > > > httpclient.close();
> > > > > > Thread.sleep(5);
> > > > > > }
> > > > > >
> > > > > >
> > > > > > }
> > > > > >
> > > > > > }
> > > > > >
> > > > > >
> > > > > > 2016-02-02 20:51 GMT+01:00 Oleg Kalnichevski :
> > > > > >
> > > > > > > On Tue, 2016-02-02 at 20:42 +0100, David Skalka wrote:
> > > > > > > > sorry i dont understand you. What do you mean by "what does
> > this
> > > all
> > > > > tell
> > > > > > > > you" ?
> > > > > > > >
> > > > > > >
> > > > > > > Have you taken even a cursory look at your own data?
> > > > > > >
> > > > > > > What makes you think there is a leak in HttpClient?
> > > > > > >
> > > > > > > Oleg
> > > > > > >
> > > > > > > > 2016-02-02 20:21 GMT+01:00 Oleg Kalnichevski <
> ol...@apache.org
> > >:
> > > > > > > >
> > > > > > > > > On Tue, 2016-02-02 at 19:30 +0100, David Skalka wrote:
> > > > > > > > > > Here is long running snapshot with types
> > > > > > > > > >
> > > > > > > > > >
> > > https://drive.google.com/open?id=0B8cERbS5JTTtZkVpWmhVWS11UkU
> > > > > > > > >
> > > > > > > > > And what does this all tell you?
> > > > > > > > >
> > > > > > > > > Oleg
> > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > 2016-02-02 17:22 GMT+01:00 Gary Gregory <
> > > garydgreg...@gmail.com
> > > > > >:
> > > > > > > > > >
> > > > > > > > > > > Can you look and see what kind of objects are retained?
> > > > > > > > > > >
> > > > > > > > > > > Gary
> > > > > > > > > > > On Feb 2, 2016 2:33 AM, "David Skalka" <
> > > david.ska...@gmail.com
> > > > > >
> > > > > > > wrote:
> > > > > > > > > > >
> > > > > > > > > > > > Why this code causes a memory leak?
> > > > > > > > > > > >
> > > > >

Re: HttpClientBuilder Memory Leak

2016-02-02 Thread Dan Quaroni
I don't really know what program is producing this image, but what I see in
this picture is that there are a lot of Strings in memory, which seem to be
living in HashMap(s).  I don't know how this program he used analyzes
memory usage... But either way, I can't reproduce it.

On Tue, Feb 2, 2016 at 3:36 PM, Oleg Kalnichevski  wrote:

> On Tue, 2016-02-02 at 15:29 -0500, Dan Quaroni wrote:
> > What version of HttpClient are you using?  I cut the sleep down to 1ms
> and
> > have had it running for 25 minutes and am not observing any such memory
> > leak.
> >
>
> If one takes even a cursory look at the memory profile one can clearly
> see that out several dozen classes on the heap only one class belongs to
> HttpCient - CPool and there are only ~900 instances of that class
> compared to millions of instances of other classes.
>
> Oleg
>
> > On Tue, Feb 2, 2016 at 3:21 PM, Oleg Kalnichevski 
> wrote:
> >
> > > On Tue, 2016-02-02 at 21:16 +0100, David Skalka wrote:
> > > > what is it "own data" ?
> > > >
> > >
> > > https://drive.google.com/open?id=0B8cERbS5JTTtZkVpWmhVWS11UkU
> > >
> > > Oleg
> > >
> > >
> > > > 2016-02-02 21:11 GMT+01:00 Oleg Kalnichevski :
> > > >
> > > > > On Tue, 2016-02-02 at 20:58 +0100, David Skalka wrote:
> > > > > > it is simple test application with one while. here is whole
> source
> > > code:
> > > > > >
> > > > >
> > > > > Have you looked at your own data?
> > > > >
> > > > > Oleg
> > > > >
> > > > > >
> > > > > > import java.io.IOException;
> > > > > >
> > > > > > import org.apache.http.impl.client.CloseableHttpClient;
> > > > > > import org.apache.http.impl.client.HttpClientBuilder;
> > > > > >
> > > > > >
> > > > > > public class Program {
> > > > > >
> > > > > > public static void main(String[] args) throws IOException,
> > > > > > InterruptedException {
> > > > > >
> > > > > > while(true){
> > > > > > CloseableHttpClient httpclient =
> > > > > > HttpClientBuilder.create().build();
> > > > > > httpclient.close();
> > > > > > Thread.sleep(5);
> > > > > > }
> > > > > >
> > > > > >
> > > > > > }
> > > > > >
> > > > > > }
> > > > > >
> > > > > >
> > > > > > 2016-02-02 20:51 GMT+01:00 Oleg Kalnichevski :
> > > > > >
> > > > > > > On Tue, 2016-02-02 at 20:42 +0100, David Skalka wrote:
> > > > > > > > sorry i dont understand you. What do you mean by "what does
> this
> > > all
> > > > > tell
> > > > > > > > you" ?
> > > > > > > >
> > > > > > >
> > > > > > > Have you taken even a cursory look at your own data?
> > > > > > >
> > > > > > > What makes you think there is a leak in HttpClient?
> > > > > > >
> > > > > > > Oleg
> > > > > > >
> > > > > > > > 2016-02-02 20:21 GMT+01:00 Oleg Kalnichevski <
> ol...@apache.org>:
> > > > > > > >
> > > > > > > > > On Tue, 2016-02-02 at 19:30 +0100, David Skalka wrote:
> > > > > > > > > > Here is long running snapshot with types
> > > > > > > > > >
> > > > > > > > > >
> > > https://drive.google.com/open?id=0B8cERbS5JTTtZkVpWmhVWS11UkU
> > > > > > > > >
> > > > > > > > > And what does this all tell you?
> > > > > > > > >
> > > > > > > > > Oleg
> > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > 2016-02-02 17:22 GMT+01:00 Gary Gregory <
> > > garydgreg...@gmail.com
> > > > > >:
> > > > > > > > > >
> > > > > > > > > > > Can you look and see what kind of objects are retaine

Re: HttpClientBuilder Memory Leak

2016-02-03 Thread Dan Quaroni
David, can you try profiling it using visualvm and see if you can reproduce
the results?

On Wed, Feb 3, 2016 at 3:06 PM, David Skalka  wrote:

> Sorry for delay.
>
> java varsion is 1.8.0. 66-b17.  The graph was made by Jprofiler.
>
> I tested same code with Yourkit a Jconsole wihout any leak. I dont
> understand it.
>
> Can someone profile this code using JProfiler? It looks at the serious
> errors of JProfiler
>
>
> 2016-02-02 23:15 GMT+01:00 Gary Gregory :
>
> > Curious: What profiler and java version are you using?
> >
> > Gary
> >
> > On Tue, Feb 2, 2016 at 1:39 PM, David Skalka 
> > wrote:
> >
> > > I updated httpclient to 4.5.1  and after 30minutes I see same result.
> > > memory is growing up
> > >
> > > 2016-02-02 21:51 GMT+01:00 Dan Quaroni :
> > >
> > > > I don't really know what program is producing this image, but what I
> > see
> > > in
> > > > this picture is that there are a lot of Strings in memory, which seem
> > to
> > > be
> > > > living in HashMap(s).  I don't know how this program he used analyzes
> > > > memory usage... But either way, I can't reproduce it.
> > > >
> > > > On Tue, Feb 2, 2016 at 3:36 PM, Oleg Kalnichevski 
> > > > wrote:
> > > >
> > > > > On Tue, 2016-02-02 at 15:29 -0500, Dan Quaroni wrote:
> > > > > > What version of HttpClient are you using?  I cut the sleep down
> to
> > > 1ms
> > > > > and
> > > > > > have had it running for 25 minutes and am not observing any such
> > > memory
> > > > > > leak.
> > > > > >
> > > > >
> > > > > If one takes even a cursory look at the memory profile one can
> > clearly
> > > > > see that out several dozen classes on the heap only one class
> belongs
> > > to
> > > > > HttpCient - CPool and there are only ~900 instances of that class
> > > > > compared to millions of instances of other classes.
> > > > >
> > > > > Oleg
> > > > >
> > > > > > On Tue, Feb 2, 2016 at 3:21 PM, Oleg Kalnichevski <
> > ol...@apache.org>
> > > > > wrote:
> > > > > >
> > > > > > > On Tue, 2016-02-02 at 21:16 +0100, David Skalka wrote:
> > > > > > > > what is it "own data" ?
> > > > > > > >
> > > > > > >
> > > > > > > https://drive.google.com/open?id=0B8cERbS5JTTtZkVpWmhVWS11UkU
> > > > > > >
> > > > > > > Oleg
> > > > > > >
> > > > > > >
> > > > > > > > 2016-02-02 21:11 GMT+01:00 Oleg Kalnichevski <
> ol...@apache.org
> > >:
> > > > > > > >
> > > > > > > > > On Tue, 2016-02-02 at 20:58 +0100, David Skalka wrote:
> > > > > > > > > > it is simple test application with one while. here is
> whole
> > > > > source
> > > > > > > code:
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > > Have you looked at your own data?
> > > > > > > > >
> > > > > > > > > Oleg
> > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > import java.io.IOException;
> > > > > > > > > >
> > > > > > > > > > import org.apache.http.impl.client.CloseableHttpClient;
> > > > > > > > > > import org.apache.http.impl.client.HttpClientBuilder;
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > public class Program {
> > > > > > > > > >
> > > > > > > > > > public static void main(String[] args) throws
> > > IOException,
> > > > > > > > > > InterruptedException {
> > > > > > > > > >
> > > > > > > > > > while(true){
> > > > > > > > > > CloseableHttpClient httpclient =
> > > > > > > > > > HttpClientBuilder.create().build();
> > > > > > > > > > httpclient.clos

Re: Apache HttpClient TCP Keep-Alive (socket keep-alive)

2016-05-11 Thread Dan Quaroni
Is there any way you can turn this into 2 requests?  1 to kick off the long
process which stores the results somewhere, and 1 to poll for the results
to get them when they're available?

On Wed, May 11, 2016 at 10:52 AM, Baratali Izmailov 
wrote:

> Hello,
>
> I have http request that takes too much time to be processed by the server
> (about 5 minutes). Because connection becomes idle for 5 minutes, proxy
> server shutdowns the connection. I'm trying to use TCP Keep-Alive in Apache
> DefaultHttpClient to make connection be alive for a long time (Not confuse
> TCP Keep-Alive with HTTP Keep-Alive that simply doesn't closes connection
> after response is sent).
>
> Apache http core has following parameter SO_KEEPALIVE:
>
> http://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/params/CoreConnectionPNames.html#SO_KEEPALIVE
> .
> However, due to DefaultHttpClient javadocs I can't customize client's
> behavior with that parameter:
>
> https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/client/DefaultHttpClient.html
> .
>
> Do you know how to make DefaultHttpClient use TCP Keep-Alive strategy?
>
>
> Thanks,
>
> Baratali.
>



-- 
_
*Daniel Quaroni*
*Principal Software Architect*

*office *781.810.2743
*mobile* 617.838.3147
q...@invoke.com


Reading only the first X bytes of the response stream

2016-09-01 Thread Dan Quaroni
I'm writing a utility that will retrieve some metadata about swf (flash)
files and I'd like to use httpclient to read the data but I want clarity on
the necessity to read the entire stream.

The information I need is all in the first few bytes of the file, and the
files could potentially be quite large so I don't want to read them in
their entirety.  I'd like to just read what I need and then close the
connection.

Here's a little test snippet, note that SWFInfo is closing the input stream
on the response entity:

public static void main(String[] args) throws Exception {

CloseableHttpClient client = buildCloseableClient();
HttpGet get = new HttpGet("http://localhost/Cat.swf";);
for (int i = 0; i < 1; i++) {
try (CloseableHttpResponse response = client.execute(get)) {
SWFInfo info =
SWFInfo.getInfo(response.getEntity().getContent());
System.out.println(i + ": " + info.width + "," +
info.height);
}
}
}


This test executes successfully, suggesting that it's OK but I want to
double check that I won't be causing any types of resource usage problems.
Note that we're using HttpClient in other parts of our application, but
those are pooled connections that are constructed differently.


Thanks,

Dan


Re: HttpClient bounded download size

2016-12-12 Thread Dan Quaroni
This code is part of a class I made to do this (In this case I needed to
grab the first 128 or so bytes of SWF files so I could parse the display
dimensions):

HttpGet get = new HttpGet(buildUrl(url));
try (CloseableHttpResponse response = client.execute(get)) {
SwfInfo info =
SwfInfo.generateInfo(response.getEntity().getContent());
 }

where generateInfo() takes the input stream from getEntity().getContent()
and then closes it:

private static byte[] getBytes(InputStream fis) {
try{
< read bytes from the input stream>

} finally {
if (fis != null) {
try {
fis.close();
} catch (IOException ee) {
}
}
}



On Mon, Dec 12, 2016 at 5:47 PM, Joseph Naegele  wrote:

> Hi all, back again.
>
> Now I'm wondering how to properly limit the number of bytes downloaded by
> the synchronous HttpClient (v4.5, i.e. most recent versions).
>
> Like the HttpAsyncClient, even if I only read the desired number of bytes
> from a response entity's InputStream, closing the entity results in the
> remainder of the response entity being downloaded from the connection. I
> found this in ContentLengthInputStream's close method, which is wrapped by
> EofSensorInputStream.
>
> Again, my goal is to intentionally collect a truncated response if it's
> larger than my limit.
>
> Thanks!
> Joe Naegele
>
>
> -
> To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
> For additional commands, e-mail: httpclient-users-h...@hc.apache.org
>
>


-- 
_
*Daniel Quaroni*
*Principal Software Architect*

*office *781.810.2743
*mobile* 617.838.3147
q...@invoke.com