Hello,

Are you able to compile and run any java programs?

What is the error you are getting, what is the command you are using to compile 
it and how does your source directory looks like?

You can compile the sample client on other machines, if this helps your 
development velocity.

You can’t really compare native program (curl) speed with Java, but it 
certainly should not be that different (I mean yes you can, it just does not 
tell you much). Do you count startup Time? How did you Test Java if it does not 
compile?

Is the only reason you look into HTTPClient the delay you see with 
URLConnection? Do you have a sample program for that which shows the slowness?
Gruss
Bernd


--
http://bernd.eckenfels.net

________________________________
Von: Somshekar C Kadam <somkada...@gmail.com>
Gesendet: Donnerstag, September 5, 2019 10:53 AM
An: HttpClient User Discussion; Somshekar kadam
Betreff: Re: apache httpclient

Hi Bernd,
Thanks for the quick reply.
Excuse me on the replyall part, my bad.

when I use curl same https connection quickly returns within 2 seconds,
ofcourse different cipher is used.
Also I am not able to get sample apache httpclient compiled on Ubuntu Linux
machine, any link or steps which I can get to make it compile and work will
help.

code
=============
package org.apache.hc.client5.http.examples;

import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;

import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;

import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import
org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder;
import org.apache.hc.client5.http.io.HttpClientConnectionManager;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactoryBuilder;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.ssl.TLS;
import org.apache.hc.core5.ssl.SSLContexts;
import org.apache.hc.core5.ssl.TrustStrategy;

/**
* This example demonstrates how to create secure connections with a custom
SSL
* context.
*/
public class ClientCustomSSL {

public final static void main(final String[] args) throws Exception {
// Trust standard CA and those trusted by our custom strategy
final SSLContext sslcontext = SSLContexts.custom()
.loadTrustMaterial(new TrustStrategy() {

@Override
public boolean isTrusted(
final X509Certificate[] chain,
final String authType) throws
CertificateException {
final X509Certificate cert = chain[0];
return "CN=httpbin.org
".equalsIgnoreCase(cert.getSubjectDN().getName());
}

})
.build();
// Allow TLSv1.2 protocol only
final SSLConnectionSocketFactory sslSocketFactory =
SSLConnectionSocketFactoryBuilder.create()
.setSslContext(SSLContexts.createSystemDefault())
.setTlsVersions(TLS.V_1_2)
.build();
final HttpClientConnectionManager cm =
PoolingHttpClientConnectionManagerBuilder.create()
.setSSLSocketFactory(sslSocketFactory)
.build();
try (CloseableHttpClient httpclient = HttpClients.custom()
.setConnectionManager(cm)
.build()) {

final HttpGet httpget = new HttpGet("https://httpbin.org/";);

System.out.println("Executing request " + httpget.getMethod() +
" " + httpget.getUri());

final HttpClientContext clientContext =
HttpClientContext.create();
try (CloseableHttpResponse response =
httpclient.execute(httpget, clientContext)) {

System.out.println("----------------------------------------");
System.out.println(response.getCode() + " " +
response.getReasonPhrase());

System.out.println(EntityUtils.toString(response.getEntity()));

final SSLSession sslSession = clientContext.getSSLSession();
if (sslSession != null) {
System.out.println("SSL protocol " +
sslSession.getProtocol());
System.out.println("SSL cipher suite " +
sslSession.getCipherSuite());
}
}
}
}

}
===================

Regards
Somshekar C Kadam
9036660538


On Thu, Sep 5, 2019 at 2:09 PM Bernd Eckenfels <e...@zusammenkunft.net>
wrote:

> Hello,
>
> Certainly you can use the Apache HTTPClient to replace URLConnection, you
> don’t need to do anything special on ARM other than having Java Runtime
> installed.
>
> If you have a slow http download changes are high this is caused by slow
> CPU, missing random numbers, slow network or server. All those conditions
> might affect URLConnection or HTTPClient, so there is no guarantee that
> switching to Apache HTTPClient will improve things.
>
> BTW your CC List is insane, why would you want to bother people like that?
> Gruss
> Bernd
>
>
> --
> http://bernd.eckenfels.net
>
> ________________________________
> Von: Somshekar C Kadam <somkada...@gmail.com>
> Gesendet: Donnerstag, September 5, 2019 10:26 AM
> An: HttpClient User Discussion
> Cc: annou...@apache.org; priv...@hc.apache.org; d...@hc.apache.org
> Betreff: apache httpclient
>
> Hi All,
> I am a newbie to Java.
> We are going to try Apache httpclient as an alternative for openjdk
> httpsurl connection class.
>
> We see that using openjdk 8 and above we s eee that when using httpsurl
> conenction we see a delay of 10 to 20 seconds to get content of the url. We
> use Armv7, Linux. We wanted first to begin with to get normal httpclient
> working on Ubuntu Linux machine.
> Dont find any steps to get it working, is there any link how to use it on
> ubuntu machine httpclient working, please point.
>
> Also you like to know hopefully this approach is correct to try Apachr
> httpsclient instaed of openjdk httpsurlconnection.
> please advice
> Regards
> Somshekar C Kadam
> 9036660538
>
>
> On Thu, Sep 5, 2019 at 1:52 PM Oleg Kalnichevski <ol...@apache.org> wrote:
>
> > The Apache HttpComponents project is pleased to announce 4.4.12 GA
> > release of HttpComponents Core.
> >
> > This is a maintenance release that corrects a number of defects
> > discovered since release 4.4.11.
> >
> > Please note that as of 4.4 HttpCore requires Java 1.6 or newer.
> >
> > IMPORTANT: Users of HttpCore 4.x GA releases are strongly encouraged to
> > evaluate new HttpCore 5.0 APIs and give the project developers
> > feedback, share critique or propose changes.
> >
> > Download -
> > <http://hc.apache.org/downloads.cgi>
> > Release notes -
> > <http://www.apache.org/dist/httpcomponents/httpcore/RELEASE_NOTES.txt>
> > HttpComponents site -
> > <http://hc.apache.org/>
> >
> > About HttpComponents Core
> >
> > HttpCore is a set of low level HTTP transport components that can be
> > used to build custom client and server side HTTP services with a
> > minimal footprint. HttpCore supports two I/O models: a blocking I/O
> > model based on the classic Java I/O and a non-blocking, event driven
> > I/O model based on Java NIO.
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
> > For additional commands, e-mail: httpclient-users-h...@hc.apache.org
> >
> >
>

Reply via email to