Re: apache httpclient

2019-09-05 Thread Bernd Eckenfels
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 
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  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 -
> 
> Release notes -
> 
> HttpComponents site -
> 
>
> 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
>
>


Re: apache httpclient

2019-09-05 Thread Somshekar C Kadam
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 
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 
> 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 begi

Re: apache httpclient

2019-09-05 Thread Bernd Eckenfels
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 
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 
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 
> Gesendet: Donn

Re: apache httpclient

2019-09-05 Thread Somshekar C Kadam
Hi Bernd,

On My Ubuntu Machine I am able to compile Intel based Java programs no
issue.
We have Armv7 target board openjdk installed, able to compile java program
and run on the board no issues,

I run the curl command on the armv7 target board, able to connect to https
link and get the content, same when I use the program below provided it
takes 15 ~20 seconds more using httpsurlconenction.


Now I wanted to try out alternative Apache httpclient to check if it can
reduce time to connect same https link. I am not able to compile the
program, I will provide the details in a while (added jar file for
httpcore).  So reuested to provide any link or steps

Thanks in advance

Regards
Somshekar C Kadam
9036660538


On Thu, Sep 5, 2019 at 2:30 PM Bernd Eckenfels 
wrote:

> 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 
> 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, clientC

Re: apache httpclient

2019-09-05 Thread Somshekar C Kadam
Hi Bernd,

Missed the sample program used
HttpsClient.java

import java.net.MalformedURLException;
import java.net.URL;
import java.security.cert.Certificate;
import java.io.*;

import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLPeerUnverifiedException;

public class HttpsClient {

   public static void main(String[] args)
   {
new HttpsClient().testIt();
   }

   private void testIt(){

   //   String https_url = "https://www.google.com/";;
String https_url = "
https://transparencyreport.google.com/https/overview?hl=en";;
  URL url;
  try {

url = new URL(https_url);
HttpsURLConnection con = (HttpsURLConnection)url.openConnection();

//dumpl all cert info
print_https_cert(con);

//dump all the content
print_content(con);

  } catch (MalformedURLException e) {
e.printStackTrace();
  } catch (IOException e) {
e.printStackTrace();
  }

   }

   private void print_https_cert(HttpsURLConnection con){

if(con!=null){

  try {

System.out.println("Response Code : " + con.getResponseCode());
System.out.println("Cipher Suite : " + con.getCipherSuite());
System.out.println("\n");

Certificate[] certs = con.getServerCertificates();
for(Certificate cert : certs){
  System.out.println("Cert Type : " + cert.getType());
  System.out.println("Cert Hash Code : " + cert.hashCode());
  System.out.println("Cert Public Key Algorithm : "
+ cert.getPublicKey().getAlgorithm());
  System.out.println("Cert Public Key Format : "
+ cert.getPublicKey().getFormat());
  System.out.println("\n");
}

} catch (SSLPeerUnverifiedException e) {
e.printStackTrace();
} catch (IOException e){
e.printStackTrace();
}

 }

   }

   private void print_content(HttpsURLConnection con){
if(con!=null){

try {

  System.out.println("** Content of the URL ");
  BufferedReader br =
new BufferedReader(
new InputStreamReader(con.getInputStream()));

  String input;

  while ((input = br.readLine()) != null){
 System.out.println(input);
  }
  br.close();

} catch (IOException e) {
  e.printStackTrace();
}

   }

   }

}
=
Regards
Somshekar C Kadam
9036660538


On Thu, Sep 5, 2019 at 2:40 PM Somshekar C Kadam 
wrote:

> Hi Bernd,
>
> On My Ubuntu Machine I am able to compile Intel based Java programs no
> issue.
> We have Armv7 target board openjdk installed, able to compile java program
> and run on the board no issues,
>
> I run the curl command on the armv7 target board, able to connect to https
> link and get the content, same when I use the program below provided it
> takes 15 ~20 seconds more using httpsurlconenction.
>
>
> Now I wanted to try out alternative Apache httpclient to check if it can
> reduce time to connect same https link. I am not able to compile the
> program, I will provide the details in a while (added jar file for
> httpcore).  So reuested to provide any link or steps
>
> Thanks in advance
>
> Regards
> Somshekar C Kadam
> 9036660538
>
>
> On Thu, Sep 5, 2019 at 2:30 PM Bernd Eckenfels 
> wrote:
>
>> 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 
>> 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
>> =
&g

Re: apache httpclient

2019-09-05 Thread Bernd Eckenfels
Hello,

The URLConnection code looks fine (line reading is not the most performing way 
to do it and buffer size is probably on the small side but that should not be a 
deal breaker). Maybe you can add timestamp printing so you can see where the 
delay happens. (Especially is it while print_certs which means it is the 
connection/handshake or is the print taking so long.

BTW: when measuring you also should not print to console, that can be very slow 
on embedded devices (and in general)

As soon as you provide us the error details we can help you with that, I don’t 
think there are specific compile instructions available for arm.

Gruss
Bernd


--
http://bernd.eckenfels.net


Von: Somshekar C Kadam 
Gesendet: Donnerstag, September 5, 2019 11:15 AM
An: HttpClient User Discussion
Betreff: Re: apache httpclient

Hi Bernd,

Missed the sample program used
HttpsClient.java

import java.net.MalformedURLException;
import java.net.URL;
import java.security.cert.Certificate;
import java.io.*;

import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLPeerUnverifiedException;

public class HttpsClient {

public static void main(String[] args)
{
new HttpsClient().testIt();
}

private void testIt(){

// String https_url = "https://www.google.com/";;
String https_url = "
https://transparencyreport.google.com/https/overview?hl=en";;
URL url;
try {

url = new URL(https_url);
HttpsURLConnection con = (HttpsURLConnection)url.openConnection();

//dumpl all cert info
print_https_cert(con);

//dump all the content
print_content(con);

} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

}

private void print_https_cert(HttpsURLConnection con){

if(con!=null){

try {

System.out.println("Response Code : " + con.getResponseCode());
System.out.println("Cipher Suite : " + con.getCipherSuite());
System.out.println("\n");

Certificate[] certs = con.getServerCertificates();
for(Certificate cert : certs){
System.out.println("Cert Type : " + cert.getType());
System.out.println("Cert Hash Code : " + cert.hashCode());
System.out.println("Cert Public Key Algorithm : "
+ cert.getPublicKey().getAlgorithm());
System.out.println("Cert Public Key Format : "
+ cert.getPublicKey().getFormat());
System.out.println("\n");
}

} catch (SSLPeerUnverifiedException e) {
e.printStackTrace();
} catch (IOException e){
e.printStackTrace();
}

}

}

private void print_content(HttpsURLConnection con){
if(con!=null){

try {

System.out.println("** Content of the URL ");
BufferedReader br =
new BufferedReader(
new InputStreamReader(con.getInputStream()));

String input;

while ((input = br.readLine()) != null){
System.out.println(input);
}
br.close();

} catch (IOException e) {
e.printStackTrace();
}

}

}

}
=
Regards
Somshekar C Kadam
9036660538


On Thu, Sep 5, 2019 at 2:40 PM Somshekar C Kadam 
wrote:

> Hi Bernd,
>
> On My Ubuntu Machine I am able to compile Intel based Java programs no
> issue.
> We have Armv7 target board openjdk installed, able to compile java program
> and run on the board no issues,
>
> I run the curl command on the armv7 target board, able to connect to https
> link and get the content, same when I use the program below provided it
> takes 15 ~20 seconds more using httpsurlconenction.
>
>
> Now I wanted to try out alternative Apache httpclient to check if it can
> reduce time to connect same https link. I am not able to compile the
> program, I will provide the details in a while (added jar file for
> httpcore). So reuested to provide any link or steps
>
> Thanks in advance
>
> Regards
> Somshekar C Kadam
> 9036660538
>
>
> On Thu, Sep 5, 2019 at 2:30 PM Bernd Eckenfels 
> wrote:
>
>> 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 
>> Gesendet: Donner

Re: apache httpclient

2019-09-05 Thread Somshekar C Kadam
Hi Brenda,

First of all thanks for your time and advice.
 I am not asking for Arm, I was telling for Intel Ubuntu Linux machine, not
able to get it compiled.

I will send error to you later.

Regards Somshekar

On Thu, Sep 5, 2019, 3:05 PM Bernd Eckenfels  wrote:

> Hello,
>
> The URLConnection code looks fine (line reading is not the most performing
> way to do it and buffer size is probably on the small side but that should
> not be a deal breaker). Maybe you can add timestamp printing so you can see
> where the delay happens. (Especially is it while print_certs which means it
> is the connection/handshake or is the print taking so long.
>
> BTW: when measuring you also should not print to console, that can be very
> slow on embedded devices (and in general)
>
> As soon as you provide us the error details we can help you with that, I
> don’t think there are specific compile instructions available for arm.
>
> Gruss
> Bernd
>
>
> --
> http://bernd.eckenfels.net
>
> 
> Von: Somshekar C Kadam 
> Gesendet: Donnerstag, September 5, 2019 11:15 AM
> An: HttpClient User Discussion
> Betreff: Re: apache httpclient
>
> Hi Bernd,
>
> Missed the sample program used
> HttpsClient.java
> 
> import java.net.MalformedURLException;
> import java.net.URL;
> import java.security.cert.Certificate;
> import java.io.*;
>
> import javax.net.ssl.HttpsURLConnection;
> import javax.net.ssl.SSLPeerUnverifiedException;
>
> public class HttpsClient {
>
> public static void main(String[] args)
> {
> new HttpsClient().testIt();
> }
>
> private void testIt(){
>
> // String https_url = "https://www.google.com/";;
> String https_url = "
> https://transparencyreport.google.com/https/overview?hl=en";;
> URL url;
> try {
>
> url = new URL(https_url);
> HttpsURLConnection con = (HttpsURLConnection)url.openConnection();
>
> //dumpl all cert info
> print_https_cert(con);
>
> //dump all the content
> print_content(con);
>
> } catch (MalformedURLException e) {
> e.printStackTrace();
> } catch (IOException e) {
> e.printStackTrace();
> }
>
> }
>
> private void print_https_cert(HttpsURLConnection con){
>
> if(con!=null){
>
> try {
>
> System.out.println("Response Code : " + con.getResponseCode());
> System.out.println("Cipher Suite : " + con.getCipherSuite());
> System.out.println("\n");
>
> Certificate[] certs = con.getServerCertificates();
> for(Certificate cert : certs){
> System.out.println("Cert Type : " + cert.getType());
> System.out.println("Cert Hash Code : " + cert.hashCode());
> System.out.println("Cert Public Key Algorithm : "
> + cert.getPublicKey().getAlgorithm());
> System.out.println("Cert Public Key Format : "
> + cert.getPublicKey().getFormat());
> System.out.println("\n");
> }
>
> } catch (SSLPeerUnverifiedException e) {
> e.printStackTrace();
> } catch (IOException e){
> e.printStackTrace();
> }
>
> }
>
> }
>
> private void print_content(HttpsURLConnection con){
> if(con!=null){
>
> try {
>
> System.out.println("** Content of the URL ");
> BufferedReader br =
> new BufferedReader(
> new InputStreamReader(con.getInputStream()));
>
> String input;
>
> while ((input = br.readLine()) != null){
> System.out.println(input);
> }
> br.close();
>
> } catch (IOException e) {
> e.printStackTrace();
> }
>
> }
>
> }
>
> }
> =
> Regards
> Somshekar C Kadam
> 9036660538
>
>
> On Thu, Sep 5, 2019 at 2:40 PM Somshekar C Kadam 
> wrote:
>
> > Hi Bernd,
> >
> > On My Ubuntu Machine I am able to compile Intel based Java programs no
> > issue.
> > We have Armv7 target board openjdk installed, able to compile java
> program
> > and run on the board no issues,
> >
> > I run the curl command on the armv7 target board, able to connect to
> https
> > link and get the content, same when I use the program below provided it
> > takes 15 ~20 seconds more using httpsurlconenction.
> >
> >
> > Now I wanted to try out alternative Apache httpclient to check if it can
> > reduce time to connect same https link. I am not able to compile the
> > program, I will provide the details in a while (added jar file for
> > httpcore). So reuested to provide any link or steps
> >
> > Thanks in advance
> >
> > Regards
> > Somshekar C Kadam
> > 9036660538
> >
> >
> > On Thu, Sep 5, 2019 at 2:30 PM Bernd Eckenfels 
&g

RE: apache httpclient

2019-09-05 Thread yossi
One possible explanation for the 20 second delay is that the curl call goes 
through a proxy (defined by the http_proxy/https_proxy environment properties), 
while Java does not pick up these properties. If this is indeed the case, you 
need to pass some system properties in your java call. See the documentation: 
https://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html.

Yossi.

-Original Message-
From: Somshekar C Kadam  
Sent: Thursday, 5 September 2019 12:45
To: HttpClient User Discussion 
Subject: Re: apache httpclient

Hi Brenda,

First of all thanks for your time and advice.
 I am not asking for Arm, I was telling for Intel Ubuntu Linux machine, not 
able to get it compiled.

I will send error to you later.

Regards Somshekar

On Thu, Sep 5, 2019, 3:05 PM Bernd Eckenfels  wrote:

> Hello,
>
> The URLConnection code looks fine (line reading is not the most 
> performing way to do it and buffer size is probably on the small side 
> but that should not be a deal breaker). Maybe you can add timestamp 
> printing so you can see where the delay happens. (Especially is it 
> while print_certs which means it is the connection/handshake or is the print 
> taking so long.
>
> BTW: when measuring you also should not print to console, that can be 
> very slow on embedded devices (and in general)
>
> As soon as you provide us the error details we can help you with that, 
> I don’t think there are specific compile instructions available for arm.
>
> Gruss
> Bernd
>
>
> --
> http://bernd.eckenfels.net
>
> 
> Von: Somshekar C Kadam 
> Gesendet: Donnerstag, September 5, 2019 11:15 AM
> An: HttpClient User Discussion
> Betreff: Re: apache httpclient
>
> Hi Bernd,
>
> Missed the sample program used
> HttpsClient.java
> 
> import java.net.MalformedURLException; import java.net.URL; import 
> java.security.cert.Certificate; import java.io.*;
>
> import javax.net.ssl.HttpsURLConnection; import 
> javax.net.ssl.SSLPeerUnverifiedException;
>
> public class HttpsClient {
>
> public static void main(String[] args) { new HttpsClient().testIt(); }
>
> private void testIt(){
>
> // String https_url = "https://www.google.com/";; String https_url = "
> https://transparencyreport.google.com/https/overview?hl=en";;
> URL url;
> try {
>
> url = new URL(https_url);
> HttpsURLConnection con = (HttpsURLConnection)url.openConnection();
>
> //dumpl all cert info
> print_https_cert(con);
>
> //dump all the content
> print_content(con);
>
> } catch (MalformedURLException e) {
> e.printStackTrace();
> } catch (IOException e) {
> e.printStackTrace();
> }
>
> }
>
> private void print_https_cert(HttpsURLConnection con){
>
> if(con!=null){
>
> try {
>
> System.out.println("Response Code : " + con.getResponseCode()); 
> System.out.println("Cipher Suite : " + con.getCipherSuite()); 
> System.out.println("\n");
>
> Certificate[] certs = con.getServerCertificates(); for(Certificate 
> cert : certs){ System.out.println("Cert Type : " + cert.getType()); 
> System.out.println("Cert Hash Code : " + cert.hashCode()); 
> System.out.println("Cert Public Key Algorithm : "
> + cert.getPublicKey().getAlgorithm());
> System.out.println("Cert Public Key Format : "
> + cert.getPublicKey().getFormat());
> System.out.println("\n");
> }
>
> } catch (SSLPeerUnverifiedException e) { e.printStackTrace(); } catch 
> (IOException e){ e.printStackTrace(); }
>
> }
>
> }
>
> private void print_content(HttpsURLConnection con){ if(con!=null){
>
> try {
>
> System.out.println("** Content of the URL "); 
> BufferedReader br = new BufferedReader( new 
> InputStreamReader(con.getInputStream()));
>
> String input;
>
> while ((input = br.readLine()) != null){ System.out.println(input); } 
> br.close();
>
> } catch (IOException e) {
> e.printStackTrace();
> }
>
> }
>
> }
>
> }
> =
> Regards
> Somshekar C Kadam
> 9036660538
>
>
> On Thu, Sep 5, 2019 at 2:40 PM Somshekar C Kadam 
> 
> wrote:
>
> > Hi Bernd,
> >
> > On My Ubuntu Machine I am able to compile Intel based Java programs 
> > no issue.
> > We have Armv7 target board openjdk installed, able to compile java
> program
> > and run on the board no issues,
> >
> > I run the curl command on the armv7 target board, able to connect to
> https
> > link and get the content, same when I use the program below provided 
> > it takes 15 ~20 seconds more using httpsurlconenction.
&

Re: apache httpclient

2019-09-05 Thread Somshekar C Kadam
Hi Yossi,

will try and get back on this.

Regards
Somshekar C Kadam
9036660538


On Thu, Sep 5, 2019 at 3:24 PM  wrote:

> One possible explanation for the 20 second delay is that the curl call
> goes through a proxy (defined by the http_proxy/https_proxy environment
> properties), while Java does not pick up these properties. If this is
> indeed the case, you need to pass some system properties in your java call.
> See the documentation:
> https://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html.
>
> Yossi.
>
> -Original Message-
> From: Somshekar C Kadam 
> Sent: Thursday, 5 September 2019 12:45
> To: HttpClient User Discussion 
> Subject: Re: apache httpclient
>
> Hi Brenda,
>
> First of all thanks for your time and advice.
>  I am not asking for Arm, I was telling for Intel Ubuntu Linux machine,
> not able to get it compiled.
>
> I will send error to you later.
>
> Regards Somshekar
>
> On Thu, Sep 5, 2019, 3:05 PM Bernd Eckenfels 
> wrote:
>
> > Hello,
> >
> > The URLConnection code looks fine (line reading is not the most
> > performing way to do it and buffer size is probably on the small side
> > but that should not be a deal breaker). Maybe you can add timestamp
> > printing so you can see where the delay happens. (Especially is it
> > while print_certs which means it is the connection/handshake or is the
> print taking so long.
> >
> > BTW: when measuring you also should not print to console, that can be
> > very slow on embedded devices (and in general)
> >
> > As soon as you provide us the error details we can help you with that,
> > I don’t think there are specific compile instructions available for arm.
> >
> > Gruss
> > Bernd
> >
> >
> > --
> > http://bernd.eckenfels.net
> >
> > 
> > Von: Somshekar C Kadam 
> > Gesendet: Donnerstag, September 5, 2019 11:15 AM
> > An: HttpClient User Discussion
> > Betreff: Re: apache httpclient
> >
> > Hi Bernd,
> >
> > Missed the sample program used
> > HttpsClient.java
> > 
> > import java.net.MalformedURLException; import java.net.URL; import
> > java.security.cert.Certificate; import java.io.*;
> >
> > import javax.net.ssl.HttpsURLConnection; import
> > javax.net.ssl.SSLPeerUnverifiedException;
> >
> > public class HttpsClient {
> >
> > public static void main(String[] args) { new HttpsClient().testIt(); }
> >
> > private void testIt(){
> >
> > // String https_url = "https://www.google.com/";; String https_url = "
> > https://transparencyreport.google.com/https/overview?hl=en";;
> > URL url;
> > try {
> >
> > url = new URL(https_url);
> > HttpsURLConnection con = (HttpsURLConnection)url.openConnection();
> >
> > //dumpl all cert info
> > print_https_cert(con);
> >
> > //dump all the content
> > print_content(con);
> >
> > } catch (MalformedURLException e) {
> > e.printStackTrace();
> > } catch (IOException e) {
> > e.printStackTrace();
> > }
> >
> > }
> >
> > private void print_https_cert(HttpsURLConnection con){
> >
> > if(con!=null){
> >
> > try {
> >
> > System.out.println("Response Code : " + con.getResponseCode());
> > System.out.println("Cipher Suite : " + con.getCipherSuite());
> > System.out.println("\n");
> >
> > Certificate[] certs = con.getServerCertificates(); for(Certificate
> > cert : certs){ System.out.println("Cert Type : " + cert.getType());
> > System.out.println("Cert Hash Code : " + cert.hashCode());
> > System.out.println("Cert Public Key Algorithm : "
> > + cert.getPublicKey().getAlgorithm());
> > System.out.println("Cert Public Key Format : "
> > + cert.getPublicKey().getFormat());
> > System.out.println("\n");
> > }
> >
> > } catch (SSLPeerUnverifiedException e) { e.printStackTrace(); } catch
> > (IOException e){ e.printStackTrace(); }
> >
> > }
> >
> > }
> >
> > private void print_content(HttpsURLConnection con){ if(con!=null){
> >
> > try {
> >
> > System.out.println("** Content of the URL ");
> > BufferedReader br = new BufferedReader( new
> > InputStreamReader(con.getInputStream()));
> >
> > String input;
> >
> > while ((input = br.readLine()) != null){ System.out.println(input); }
> > br.close();
> >
> > } catch (IOExce

Re: apache httpclient

2019-09-05 Thread Somshekar C Kadam
lient.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 4:47 PM Somshekar C Kadam 
wrote:

> Hi Yossi,
>
> will try and get back on this.
>
> Regards
> Somshekar C Kadam
> 9036660538
>
>
> On Thu, Sep 5, 2019 at 3:24 PM  wrote:
>
>> One possible explanation for the 20 second delay is that the curl call
>> goes through a proxy (defined by the http_proxy/https_proxy environment
>> properties), while Java does not pick up these properties. If this is
>> indeed the case, you need to pass some system properties in your java call.
>> See the documentation:
>> https://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html.
>>
>> Yossi.
>>
>> -Original Message-
>> From: Somshekar C Kadam 
>> Sent: Thursday, 5 September 2019 12:45
>> To: HttpClient User Discussion 
>> Subject: Re: apache httpclient
>>
>> Hi Brenda,
>>
>> First of all thanks for your time and advice.
>>  I am not asking for Arm, I was telling for Intel Ubuntu Linux machine,
>> not able to get it compiled.
>>
>> I will send error to you later.
>>
>> Regards Somshekar
>>
>> On Thu, Sep 5, 2019, 3:05 PM Bernd Eckenfels 
>> wrote:
>>
>> > Hello,
>> >
>> > The URLConnection code looks fine (line reading is not the most
>> > performing way to do it and buffer size is probably on the small side
>> > but that should not be a deal breaker). Maybe you can add timestamp
>> > printing so you can see where the delay happens. (Especially is it
>> > while print_certs which means it is the connection/handshake or is the
>> print taking so long.
>> >
>> > BTW: when measuring you also should not print to console, that can be
>> > very slow on embedded devices (and in general)
>> >
>> > As soon as you provide us the error details we can help you with that,
>> > I don’t think there are specific compile instructions available for arm.
>> >
>> > Gruss
>> > Bernd
>> >
>> >
>> > --
>> > http://bernd.eckenfels.net
>> >
>> > 
>> > Von: Somshekar C Kadam 
>> > Gesendet: Donnerstag, September 5, 2019 11:15 AM
>> > An: HttpClient User Discussion
>> > Betreff: Re: apache httpclient
>> >
>> > Hi Bernd,
>> >
>> > Missed the sample program used
>> > HttpsClient.java
>> > 
>> > import java.net.MalformedURLException; import java.net.URL; import
>> > java.security.cert.Certificate; import java.io.*;
>> >
>> > import javax.net.ssl.HttpsURLConnection; import
>> > javax.net.ssl.SSLPeerUnverifiedException;
>> >
>> > public class HttpsClient {
>> >
>> > public static void main(String[] args) { new HttpsClient().testIt(); }
>> >
>> > private void testIt(){
>> >
>> > // String https_url = "https://www.google.com/";; String https_url = "
>> > https://transparencyreport.google.com/https/overview?hl=en";;
>> > URL url;
>> > try {
>> >
>> > url = new URL(https_url);
>> > HttpsURLConnection con = (HttpsURLConnection)url.openConnection();
>> >
>> > //dumpl all cert info
>> > print_https_cert(con);
>> >
>> > //dump all the content
>> > print_content(con);
>> >
>> > } catch (MalformedURLException e) {
>> > e.printStackTrace();
>> > } catch (IOException e) {
>> > e.printStackTrace();
>> > }
>> >
>> > }
>> >
>> > private void print_https_cert(HttpsURLConnection con){
>> >
>> > if(con!=null){
>> >
>> > try {
>> >
>> > System.out.println("Response Code : " + con.getResponseCode());
>> > System.out.println("Cipher Suite : " + con.getC

RE: apache httpclient

2019-09-05 Thread yossi
The compilation error are the result of you coping code from HC version 5.0 and 
using it with JARs for HC 4.5.x. The hint is in the package name (client5).
I suggest you look for examples for the current version (4.5.x).


-Original Message-
From: Somshekar C Kadam  
Sent: Thursday, 5 September 2019 14:28
To: HttpClient User Discussion 
Subject: Re: apache httpclient

Hi Bernd,

I am using java 1.8, Ubuntu 16.04, code is given below which I am trying to 
compile which uses apache httpclient.

httpclient jar fies downloaded

somshekar@celsys041:~$ ls
/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/
commons-codec-1.11.jar   httpclient-4.5.9.jar
 httpclient-win-4.5.9.jar  jna-4.5.2.jar commons-logging-1.2.jar  
httpclient-cache-4.5.9.jar  httpcore-4.4.11.jar
jna-platform-4.5.2.jar
fluent-hc-4.5.9.jar  httpclient-osgi-4.5.9.jar   httpmime-4.5.9.jar

error log

somshekar@celsys041:~$ javac -classpath
/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpcore-4.4.11.jar
ClientCustomSSL.java
ClientCustomSSL.java:9: error: package
org.apache.hc.client5.http.classic.methods does not exist import 
org.apache.hc.client5.http.classic.methods.HttpGet;
 ^
ClientCustomSSL.java:10: error: package
org.apache.hc.client5.http.impl.classic does not exist import 
org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
  ^
ClientCustomSSL.java:11: error: package
org.apache.hc.client5.http.impl.classic does not exist import 
org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
  ^
ClientCustomSSL.java:12: error: package
org.apache.hc.client5.http.impl.classic does not exist import 
org.apache.hc.client5.http.impl.classic.HttpClients;
  ^
ClientCustomSSL.java:13: error: package org.apache.hc.client5.http.impl.io
does not exist
import
org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder;
 ^
ClientCustomSSL.java:14: error: package org.apache.hc.client5.http.io does not 
exist import org.apache.hc.client5.http.io.HttpClientConnectionManager;
^
ClientCustomSSL.java:15: error: package org.apache.hc.client5.http.protocol
does not exist
import org.apache.hc.client5.http.protocol.HttpClientContext;
  ^
ClientCustomSSL.java:16: error: package org.apache.hc.client5.http.ssl does not 
exist import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
 ^
ClientCustomSSL.java:17: error: package org.apache.hc.client5.http.ssl does not 
exist import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactoryBuilder;
 ^
ClientCustomSSL.java:18: error: package org.apache.hc.core5.http.io.entity
does not exist
import org.apache.hc.core5.http.io.entity.EntityUtils;
 ^
ClientCustomSSL.java:19: error: package org.apache.hc.core5.http.ssl does not 
exist import org.apache.hc.core5.http.ssl.TLS;
   ^
ClientCustomSSL.java:20: error: package org.apache.hc.core5.ssl does not exist 
import org.apache.hc.core5.ssl.SSLContexts;
  ^
ClientCustomSSL.java:21: error: package org.apache.hc.core5.ssl does not exist 
import org.apache.hc.core5.ssl.TrustStrategy;
  ^
ClientCustomSSL.java:32: error: cannot find symbol
.loadTrustMaterial(new TrustStrategy() {
   ^
  symbol:   class TrustStrategy
  location: class ClientCustomSSL
ClientCustomSSL.java:34: error: method does not override or implement a method 
from a supertype
@Override
^
ClientCustomSSL.java:31: error: cannot find symbol
final SSLContext sslcontext = SSLContexts.custom()
  ^
  symbol:   variable SSLContexts
  location: class ClientCustomSSL
ClientCustomSSL.java:45: error: cannot find symbol
final SSLConnectionSocketFactory sslSocketFactory =
SSLConnectionSocketFactoryBuilder.create()
  ^
  symbol:   class SSLConnectionSocketFactory
  location: class ClientCustomSSL
ClientCustomSSL.java:47: error: cannot find symbol
.setTlsVersions(TLS.V_1_2)
^
  symbol:   variable TLS
  location: class ClientCustomSSL
ClientCustomSSL.java:45: error: cannot find symbol
final SSLConnectionSocketFactory sslSocketFactory =
SSLConnectionSocketFactoryBuilder.create()
^
  symbol:   variable SSLConnectionSocketFactoryBuilder
  location: class ClientCustomSSL
ClientCustomSSL.java:46: error: cannot find symbol
.setSslContext

Re: apache httpclient

2019-09-05 Thread Somshekar C Kadam
te:

> The compilation error are the result of you coping code from HC version
> 5.0 and using it with JARs for HC 4.5.x. The hint is in the package name
> (client5).
> I suggest you look for examples for the current version (4.5.x).
>
>
> -Original Message-
> From: Somshekar C Kadam 
> Sent: Thursday, 5 September 2019 14:28
> To: HttpClient User Discussion 
> Subject: Re: apache httpclient
>
> Hi Bernd,
>
> I am using java 1.8, Ubuntu 16.04, code is given below which I am trying
> to compile which uses apache httpclient.
>
> httpclient jar fies downloaded
>
> somshekar@celsys041:~$ ls
> /home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/
> commons-codec-1.11.jar   httpclient-4.5.9.jar
>  httpclient-win-4.5.9.jar  jna-4.5.2.jar commons-logging-1.2.jar
> httpclient-cache-4.5.9.jar  httpcore-4.4.11.jar
> jna-platform-4.5.2.jar
> fluent-hc-4.5.9.jar  httpclient-osgi-4.5.9.jar   httpmime-4.5.9.jar
>
> error log
> 
> somshekar@celsys041:~$ javac -classpath
>
> /home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpcore-4.4.11.jar
> ClientCustomSSL.java
> ClientCustomSSL.java:9: error: package
> org.apache.hc.client5.http.classic.methods does not exist import
> org.apache.hc.client5.http.classic.methods.HttpGet;
>  ^
> ClientCustomSSL.java:10: error: package
> org.apache.hc.client5.http.impl.classic does not exist import
> org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
>   ^
> ClientCustomSSL.java:11: error: package
> org.apache.hc.client5.http.impl.classic does not exist import
> org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
>   ^
> ClientCustomSSL.java:12: error: package
> org.apache.hc.client5.http.impl.classic does not exist import
> org.apache.hc.client5.http.impl.classic.HttpClients;
>   ^
> ClientCustomSSL.java:13: error: package org.apache.hc.client5.http.impl.io
> does not exist
> import
> org.apache.hc.client5.http.impl.io
> .PoolingHttpClientConnectionManagerBuilder;
>  ^
> ClientCustomSSL.java:14: error: package org.apache.hc.client5.http.io
> does not exist import org.apache.hc.client5.http.io
> .HttpClientConnectionManager;
> ^
> ClientCustomSSL.java:15: error: package org.apache.hc.client5.http.protocol
> does not exist
> import org.apache.hc.client5.http.protocol.HttpClientContext;
>   ^
> ClientCustomSSL.java:16: error: package org.apache.hc.client5.http.ssl
> does not exist import
> org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
>  ^
> ClientCustomSSL.java:17: error: package org.apache.hc.client5.http.ssl
> does not exist import
> org.apache.hc.client5.http.ssl.SSLConnectionSocketFactoryBuilder;
>  ^
> ClientCustomSSL.java:18: error: package org.apache.hc.core5.http.io.entity
> does not exist
> import org.apache.hc.core5.http.io.entity.EntityUtils;
>  ^
> ClientCustomSSL.java:19: error: package org.apache.hc.core5.http.ssl does
> not exist import org.apache.hc.core5.http.ssl.TLS;
>^
> ClientCustomSSL.java:20: error: package org.apache.hc.core5.ssl does not
> exist import org.apache.hc.core5.ssl.SSLContexts;
>   ^
> ClientCustomSSL.java:21: error: package org.apache.hc.core5.ssl does not
> exist import org.apache.hc.core5.ssl.TrustStrategy;
>   ^
> ClientCustomSSL.java:32: error: cannot find symbol
> .loadTrustMaterial(new TrustStrategy() {
>^
>   symbol:   class TrustStrategy
>   location: class ClientCustomSSL
> ClientCustomSSL.java:34: error: method does not override or implement a
> method from a supertype
> @Override
> ^
> ClientCustomSSL.java:31: error: cannot find symbol
> final SSLContext sslcontext = SSLContexts.custom()
>   ^
>   symbol:   variable SSLContexts
>   location: class ClientCustomSSL
> ClientCustomSSL.java:45: error: cannot find symbol
> final SSLConnectionSocketFactory sslSocketFactory =
> SSLConnectionSocketFactoryBuilder.create()
>   ^
>   symbol:   class SSLConnectionSocketFactory
>   location: class ClientCustomSSL
> ClientCustomSSL.java:47: error: cannot find symbol
> .setTlsVersions(TL

RE: apache httpclient

2019-09-05 Thread yossi
It seems that you are only putting httpclient-4.5.9.jar in your classpath, but 
it has dependencies on other JARs itself. Most importantly, it depends on 
HttpCore, part of the same project. You can see the dependencies, and their own 
dependencies, recursively, at 
https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient/4.5.9.
Collecting all the transitive dependencies for Java projects manually can 
become quite time-consuming. You can definitely do it for this test, but I 
recommend learning how to use Maven.

-Original Message-
From: Somshekar C Kadam  
Sent: Thursday, 5 September 2019 15:40
To: HttpClient User Discussion 
Subject: Re: apache httpclient

Hi Yossi,

Thanks for correcting me, I used example from 4.5.9, let me know if I am 
setting proper jar file or need to give any other or missing any step.

source code
=
package org.apache.http.examples.client;

import java.io.File;

import javax.net.ssl.SSLContext;

import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContexts;
import org.apache.http.util.EntityUtils;

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

public final static void main(String[] args) throws Exception {
// Trust own CA and all self-signed certs
SSLContext sslcontext = SSLContexts.custom()
.loadTrustMaterial(new File("my.keystore"), 
"nopassword".toCharArray(),
new TrustSelfSignedStrategy())
.build();
// Allow TLSv1 protocol only
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
sslcontext,
new String[] { "TLSv1" },
null,
SSLConnectionSocketFactory.getDefaultHostnameVerifier());
CloseableHttpClient httpclient = HttpClients.custom()
.setSSLSocketFactory(sslsf)
.build();
try {

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

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

CloseableHttpResponse response = httpclient.execute(httpget);
try {
HttpEntity entity = response.getEntity();


System.out.println("");
System.out.println(response.getStatusLine());
EntityUtils.consume(entity);
} finally {
response.close();
}
} finally {
httpclient.close();
}
}

}
==



Compile error logs
=
somshekar@celsys041:~$ javac -classpath
/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-4.5.9.jar
ClientCustomSSL.java
ClientCustomSSL.java:33: error: cannot find symbol import 
org.apache.http.HttpEntity;
  ^
  symbol:   class HttpEntity
  location: package org.apache.http
ClientCustomSSL.java:40: error: package org.apache.http.ssl does not exist 
import org.apache.http.ssl.SSLContexts;
  ^
ClientCustomSSL.java:41: error: package org.apache.http.util does not exist 
import org.apache.http.util.EntityUtils;
   ^
warning: unknown enum constant ThreadingBehavior.SAFE
  reason: class file for org.apache.http.annotation.ThreadingBehavior not found
warning: unknown enum constant ThreadingBehavior.SAFE
ClientCustomSSL.java:51: error: cannot find symbol
SSLContext sslcontext = SSLContexts.custom()
^
  symbol:   variable SSLContexts
  location: class ClientCustomSSL
ClientCustomSSL.java:68: error: cannot access HttpRequest
System.out.println("Executing request " + httpget.getRequestLine());
 ^
  class file for org.apache.http.HttpRequest not found
ClientCustomSSL.java:70: error: cannot access AbstractHttpMessage
CloseableHttpResponse response = httpclient.execute(httpget);
   ^
  class file for org.apache.http.message.AbstractHttpMessage not found
ClientCustomSSL.java:72: error: cannot find symbol
HttpEntity entity = response.getEntity();
^
  symbol:   class HttpEntity
  location: class ClientCustomSSL
ClientCustomSSL.java:72: error: cannot access HttpResponse
HttpEntity entity = response.getEntity();
   

Re: apache httpclient

2019-09-05 Thread Somshekar C Kadam
Hi Yossi,
Thanks you are right, I did put all jar files and compiled it, now it
compiles successfully able to create class file.

compile command

javac -classpath
/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpcore-4.4.11.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-osgi-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-cache-4.5.9.jar
ClientCustomSSL.java


somshekar@celsys041:~$ file ClientCustomSSL.class
ClientCustomSSL.class: compiled Java class data, version 52.0 (Java 1.8)


when I try to run it, it gives below error, do I have to specify the
classpath at runtime also

somshekar@celsys041:~$ sudo java -classpath
/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpcore-4.4.11.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-osgi-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-cache-4.5.9.jar
ClientCustomSSL
Error: Could not find or load main class ClientCustomSSL

thanks in advance
Regards
Somshekar C Kadam
9036660538


On Thu, Sep 5, 2019 at 6:33 PM  wrote:

> It seems that you are only putting httpclient-4.5.9.jar in your classpath,
> but it has dependencies on other JARs itself. Most importantly, it depends
> on HttpCore, part of the same project. You can see the dependencies, and
> their own dependencies, recursively, at
> https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient/4.5.9
> .
> Collecting all the transitive dependencies for Java projects manually can
> become quite time-consuming. You can definitely do it for this test, but I
> recommend learning how to use Maven.
>
> -Original Message-
> From: Somshekar C Kadam 
> Sent: Thursday, 5 September 2019 15:40
> To: HttpClient User Discussion 
> Subject: Re: apache httpclient
>
> Hi Yossi,
>
> Thanks for correcting me, I used example from 4.5.9, let me know if I am
> setting proper jar file or need to give any other or missing any step.
>
> source code
> =
> package org.apache.http.examples.client;
>
> import java.io.File;
>
> import javax.net.ssl.SSLContext;
>
> import org.apache.http.HttpEntity;
> import org.apache.http.client.methods.CloseableHttpResponse;
> import org.apache.http.client.methods.HttpGet;
> import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
> import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
> import org.apache.http.impl.client.CloseableHttpClient;
> import org.apache.http.impl.client.HttpClients;
> import org.apache.http.ssl.SSLContexts;
> import org.apache.http.util.EntityUtils;
>
> /**
>  * This example demonstrates how to create secure connections with a
> custom SSL
>  * context.
>  */
> public class ClientCustomSSL {
>
> public final static void main(String[] args) throws Exception {
> // Trust own CA and all self-signed certs
> SSLContext sslcontext = SSLContexts.custom()
> .loadTrustMaterial(new File("my.keystore"),
> "nopassword".toCharArray(),
> new TrustSelfSignedStrategy())
> .build();
> // Allow TLSv1 protocol only
> SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
> sslcontext,
> new String[] { "TLSv1" },
> null,
> SSLConnectionSocketFactory.getDefaultHostnameVerifier());
> CloseableHttpClient httpclient = HttpClients.custom()
> .setSSLSocketFactory(sslsf)
> .build();
> try {
>
> HttpGet httpget = new HttpGet("https://httpbin.org/";);
>
> System.out.println("Executing request " +
> httpget.getRequestLine());
>
> CloseableHttpResponse response = httpclient.execute(httpget);
> try {
> HttpEntity entity = response.getEntity();
>
>
> System.out.println("");
> System.out.println(response.getStatusLine());
> EntityUtils.consume(entity);
> } finally {
> response.close();
> }
> } finally {
> httpclient.close();
> }
> }
>
> }
> ==
>
>
>
> Compile error logs
> =
> somshekar@celsys041:~$ javac -classpath
>
> /home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/h

RE: apache httpclient

2019-09-05 Thread yossi
You need to specify the full package name of the main class (in your case 
org.apache.http.examples.client.ClientCustomSSL).

-Original Message-
From: Somshekar C Kadam  
Sent: Thursday, 5 September 2019 16:14
To: HttpClient User Discussion 
Subject: Re: apache httpclient

Hi Yossi,
Thanks you are right, I did put all jar files and compiled it, now it compiles 
successfully able to create class file.

compile command

javac -classpath
/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpcore-4.4.11.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-osgi-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-cache-4.5.9.jar
ClientCustomSSL.java


somshekar@celsys041:~$ file ClientCustomSSL.class
ClientCustomSSL.class: compiled Java class data, version 52.0 (Java 1.8)


when I try to run it, it gives below error, do I have to specify the classpath 
at runtime also

somshekar@celsys041:~$ sudo java -classpath 
/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpcore-4.4.11.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-osgi-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-cache-4.5.9.jar
ClientCustomSSL
Error: Could not find or load main class ClientCustomSSL

thanks in advance
Regards
Somshekar C Kadam
9036660538


On Thu, Sep 5, 2019 at 6:33 PM  wrote:

> It seems that you are only putting httpclient-4.5.9.jar in your 
> classpath, but it has dependencies on other JARs itself. Most 
> importantly, it depends on HttpCore, part of the same project. You can 
> see the dependencies, and their own dependencies, recursively, at
> https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclien
> t/4.5.9
> .
> Collecting all the transitive dependencies for Java projects manually 
> can become quite time-consuming. You can definitely do it for this 
> test, but I recommend learning how to use Maven.
>
> -Original Message-
> From: Somshekar C Kadam 
> Sent: Thursday, 5 September 2019 15:40
> To: HttpClient User Discussion 
> Subject: Re: apache httpclient
>
> Hi Yossi,
>
> Thanks for correcting me, I used example from 4.5.9, let me know if I 
> am setting proper jar file or need to give any other or missing any step.
>
> source code
> =
> package org.apache.http.examples.client;
>
> import java.io.File;
>
> import javax.net.ssl.SSLContext;
>
> import org.apache.http.HttpEntity;
> import org.apache.http.client.methods.CloseableHttpResponse;
> import org.apache.http.client.methods.HttpGet;
> import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
> import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
> import org.apache.http.impl.client.CloseableHttpClient;
> import org.apache.http.impl.client.HttpClients;
> import org.apache.http.ssl.SSLContexts; import 
> org.apache.http.util.EntityUtils;
>
> /**
>  * This example demonstrates how to create secure connections with a 
> custom SSL
>  * context.
>  */
> public class ClientCustomSSL {
>
> public final static void main(String[] args) throws Exception {
> // Trust own CA and all self-signed certs
> SSLContext sslcontext = SSLContexts.custom()
> .loadTrustMaterial(new File("my.keystore"), 
> "nopassword".toCharArray(),
> new TrustSelfSignedStrategy())
> .build();
> // Allow TLSv1 protocol only
> SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
> sslcontext,
> new String[] { "TLSv1" },
> null,
> SSLConnectionSocketFactory.getDefaultHostnameVerifier());
> CloseableHttpClient httpclient = HttpClients.custom()
> .setSSLSocketFactory(sslsf)
> .build();
> try {
>
> HttpGet httpget = new HttpGet("https://httpbin.org/";);
>
> System.out.println("Executing request " + 
> httpget.getRequestLine());
>
> CloseableHttpResponse response = httpclient.execute(httpget);
> try {
> HttpEntity entity = response.getEntity();
>
>
> System.out.println("");
> System.out.println(response.getStatusLine());
> EntityUtils.consume(entity);
> } finally {
> response.close();
> }
> } finally {
> httpcl

Re: apache httpclient

2019-09-05 Thread Somshekar C Kadam
Hi Yossi,
tried the same

somshekar@celsys041:~$ java -classpath
/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpcore-4.4.11.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-osgi-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-cache-4.5.9.jar
org.apache.http.examples.client.ClientCustomSSL
Error: Could not find or load main class
org.apache.http.examples.client.ClientCustomSSL

same even with sudo, not sure why am I missing naything else
Sorry for many mails on this

thanks in advance

Regards
Somshekar C Kadam
9036660538


On Thu, Sep 5, 2019 at 6:46 PM  wrote:

> You need to specify the full package name of the main class (in your case
> org.apache.http.examples.client.ClientCustomSSL).
>
> -Original Message-
> From: Somshekar C Kadam 
> Sent: Thursday, 5 September 2019 16:14
> To: HttpClient User Discussion 
> Subject: Re: apache httpclient
>
> Hi Yossi,
> Thanks you are right, I did put all jar files and compiled it, now it
> compiles successfully able to create class file.
>
> compile command
>
> javac -classpath
>
> /home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpcore-4.4.11.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-osgi-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-cache-4.5.9.jar
> ClientCustomSSL.java
>
>
> somshekar@celsys041:~$ file ClientCustomSSL.class
> ClientCustomSSL.class: compiled Java class data, version 52.0 (Java 1.8)
>
>
> when I try to run it, it gives below error, do I have to specify the
> classpath at runtime also
>
> somshekar@celsys041:~$ sudo java -classpath
> /home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpcore-4.4.11.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-osgi-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-cache-4.5.9.jar
> ClientCustomSSL
> Error: Could not find or load main class ClientCustomSSL
>
> thanks in advance
> Regards
> Somshekar C Kadam
> 9036660538
>
>
> On Thu, Sep 5, 2019 at 6:33 PM  wrote:
>
> > It seems that you are only putting httpclient-4.5.9.jar in your
> > classpath, but it has dependencies on other JARs itself. Most
> > importantly, it depends on HttpCore, part of the same project. You can
> > see the dependencies, and their own dependencies, recursively, at
> > https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclien
> > t/4.5.9
> > .
> > Collecting all the transitive dependencies for Java projects manually
> > can become quite time-consuming. You can definitely do it for this
> > test, but I recommend learning how to use Maven.
> >
> > -Original Message-
> > From: Somshekar C Kadam 
> > Sent: Thursday, 5 September 2019 15:40
> > To: HttpClient User Discussion 
> > Subject: Re: apache httpclient
> >
> > Hi Yossi,
> >
> > Thanks for correcting me, I used example from 4.5.9, let me know if I
> > am setting proper jar file or need to give any other or missing any step.
> >
> > source code
> > =
> > package org.apache.http.examples.client;
> >
> > import java.io.File;
> >
> > import javax.net.ssl.SSLContext;
> >
> > import org.apache.http.HttpEntity;
> > import org.apache.http.client.methods.CloseableHttpResponse;
> > import org.apache.http.client.methods.HttpGet;
> > import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
> > import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
> > import org.apache.http.impl.client.CloseableHttpClient;
> > import org.apache.http.impl.client.HttpClients;
> > import org.apache.http.ssl.SSLContexts; import
> > org.apache.http.util.EntityUtils;
> >
> > /**
> >  * This example demonstrates how to create secure connections with a
> > custom SSL
> >  * context.
> >  */
> > public class ClientCustomSSL {
> >
> > public final static void main(String[] args) throws Exception {
> > // Trust own CA and all self-signed certs
> > SSLContext sslcontext = SSLContexts.custom()
> > .loadTrustMaterial(new File("my.keystore"),
> > "nopassword".toCharArray(),
> > new TrustSelfSignedStrategy())
> > .build

RE: apache httpclient

2019-09-05 Thread yossi
Your class should also be in the classpath. Add ";path/ClientCustomSSL.class" 
to your class path.
(This is basic Java stuff, unrelated to HC. Maybe you should do some Java 
tutorial first, or if possible start using an IDE, which simplifies a lot of 
these issues.)

-Original Message-
From: Somshekar C Kadam  
Sent: Thursday, 5 September 2019 16:51
To: HttpClient User Discussion 
Subject: Re: apache httpclient

Hi Yossi,
tried the same

somshekar@celsys041:~$ java -classpath
/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpcore-4.4.11.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-osgi-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-cache-4.5.9.jar
org.apache.http.examples.client.ClientCustomSSL
Error: Could not find or load main class 
org.apache.http.examples.client.ClientCustomSSL

same even with sudo, not sure why am I missing naything else Sorry for many 
mails on this

thanks in advance

Regards
Somshekar C Kadam
9036660538


On Thu, Sep 5, 2019 at 6:46 PM  wrote:

> You need to specify the full package name of the main class (in your 
> case org.apache.http.examples.client.ClientCustomSSL).
>
> -Original Message-
> From: Somshekar C Kadam 
> Sent: Thursday, 5 September 2019 16:14
> To: HttpClient User Discussion 
> Subject: Re: apache httpclient
>
> Hi Yossi,
> Thanks you are right, I did put all jar files and compiled it, now it 
> compiles successfully able to create class file.
>
> compile command
>
> javac -classpath
>
> /home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpc
> lient-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client
> -4.5.9/lib/httpcore-4.4.11.jar:/home/somshekar/akshay/java-jvms/httpco
> mponents-client-4.5.9/lib/httpclient-osgi-4.5.9.jar:/home/somshekar/ak
> shay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-cache-4.5.9.
> jar
> ClientCustomSSL.java
>
>
> somshekar@celsys041:~$ file ClientCustomSSL.class
> ClientCustomSSL.class: compiled Java class data, version 52.0 (Java 
> 1.8)
>
>
> when I try to run it, it gives below error, do I have to specify the 
> classpath at runtime also
>
> somshekar@celsys041:~$ sudo java -classpath 
> /home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpc
> lient-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client
> -4.5.9/lib/httpcore-4.4.11.jar:/home/somshekar/akshay/java-jvms/httpco
> mponents-client-4.5.9/lib/httpclient-osgi-4.5.9.jar:/home/somshekar/ak
> shay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-cache-4.5.9.
> jar
> ClientCustomSSL
> Error: Could not find or load main class ClientCustomSSL
>
> thanks in advance
> Regards
> Somshekar C Kadam
> 9036660538
>
>
> On Thu, Sep 5, 2019 at 6:33 PM  wrote:
>
> > It seems that you are only putting httpclient-4.5.9.jar in your 
> > classpath, but it has dependencies on other JARs itself. Most 
> > importantly, it depends on HttpCore, part of the same project. You 
> > can see the dependencies, and their own dependencies, recursively, 
> > at 
> > https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcli
> > en
> > t/4.5.9
> > .
> > Collecting all the transitive dependencies for Java projects 
> > manually can become quite time-consuming. You can definitely do it 
> > for this test, but I recommend learning how to use Maven.
> >
> > -Original Message-
> > From: Somshekar C Kadam 
> > Sent: Thursday, 5 September 2019 15:40
> > To: HttpClient User Discussion 
> > Subject: Re: apache httpclient
> >
> > Hi Yossi,
> >
> > Thanks for correcting me, I used example from 4.5.9, let me know if 
> > I am setting proper jar file or need to give any other or missing any step.
> >
> > source code
> > =
> > package org.apache.http.examples.client;
> >
> > import java.io.File;
> >
> > import javax.net.ssl.SSLContext;
> >
> > import org.apache.http.HttpEntity;
> > import org.apache.http.client.methods.CloseableHttpResponse;
> > import org.apache.http.client.methods.HttpGet;
> > import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
> > import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
> > import org.apache.http.impl.client.CloseableHttpClient;
> > import org.apache.http.impl.client.HttpClients;
> > import org.apache.http.ssl.SSLContexts; import 
> > org.apache.http.util.EntityUtils;
> >
> > /**
> >  * This example demonstrates how to create secure con

Re: apache httpclient

2019-09-05 Thread Somshekar C Kadam
Yes Yossi I think I need to do that, Thanks a lot for your suggestions and
support.

Regards Somshekar

On Thu, Sep 5, 2019, 8:48 PM  wrote:

> Your class should also be in the classpath. Add
> ";path/ClientCustomSSL.class" to your class path.
> (This is basic Java stuff, unrelated to HC. Maybe you should do some Java
> tutorial first, or if possible start using an IDE, which simplifies a lot
> of these issues.)
>
> -Original Message-
> From: Somshekar C Kadam 
> Sent: Thursday, 5 September 2019 16:51
> To: HttpClient User Discussion 
> Subject: Re: apache httpclient
>
> Hi Yossi,
> tried the same
>
> somshekar@celsys041:~$ java -classpath
>
> /home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpcore-4.4.11.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-osgi-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-cache-4.5.9.jar
> org.apache.http.examples.client.ClientCustomSSL
> Error: Could not find or load main class
> org.apache.http.examples.client.ClientCustomSSL
>
> same even with sudo, not sure why am I missing naything else Sorry for
> many mails on this
>
> thanks in advance
>
> Regards
> Somshekar C Kadam
> 9036660538
>
>
> On Thu, Sep 5, 2019 at 6:46 PM  wrote:
>
> > You need to specify the full package name of the main class (in your
> > case org.apache.http.examples.client.ClientCustomSSL).
> >
> > -Original Message-----
> > From: Somshekar C Kadam 
> > Sent: Thursday, 5 September 2019 16:14
> > To: HttpClient User Discussion 
> > Subject: Re: apache httpclient
> >
> > Hi Yossi,
> > Thanks you are right, I did put all jar files and compiled it, now it
> > compiles successfully able to create class file.
> >
> > compile command
> >
> > javac -classpath
> >
> > /home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpc
> > lient-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client
> > -4.5.9/lib/httpcore-4.4.11.jar:/home/somshekar/akshay/java-jvms/httpco
> > mponents-client-4.5.9/lib/httpclient-osgi-4.5.9.jar:/home/somshekar/ak
> > shay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-cache-4.5.9.
> > jar
> > ClientCustomSSL.java
> >
> >
> > somshekar@celsys041:~$ file ClientCustomSSL.class
> > ClientCustomSSL.class: compiled Java class data, version 52.0 (Java
> > 1.8)
> >
> >
> > when I try to run it, it gives below error, do I have to specify the
> > classpath at runtime also
> >
> > somshekar@celsys041:~$ sudo java -classpath
> > /home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpc
> > lient-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client
> > -4.5.9/lib/httpcore-4.4.11.jar:/home/somshekar/akshay/java-jvms/httpco
> > mponents-client-4.5.9/lib/httpclient-osgi-4.5.9.jar:/home/somshekar/ak
> > shay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-cache-4.5.9.
> > jar
> > ClientCustomSSL
> > Error: Could not find or load main class ClientCustomSSL
> >
> > thanks in advance
> > Regards
> > Somshekar C Kadam
> > 9036660538
> >
> >
> > On Thu, Sep 5, 2019 at 6:33 PM  wrote:
> >
> > > It seems that you are only putting httpclient-4.5.9.jar in your
> > > classpath, but it has dependencies on other JARs itself. Most
> > > importantly, it depends on HttpCore, part of the same project. You
> > > can see the dependencies, and their own dependencies, recursively,
> > > at
> > > https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcli
> > > en
> > > t/4.5.9
> > > .
> > > Collecting all the transitive dependencies for Java projects
> > > manually can become quite time-consuming. You can definitely do it
> > > for this test, but I recommend learning how to use Maven.
> > >
> > > -Original Message-
> > > From: Somshekar C Kadam 
> > > Sent: Thursday, 5 September 2019 15:40
> > > To: HttpClient User Discussion 
> > > Subject: Re: apache httpclient
> > >
> > > Hi Yossi,
> > >
> > > Thanks for correcting me, I used example from 4.5.9, let me know if
> > > I am setting proper jar file or need to give any other or missing any
> step.
> > >
> > > source code
> > > =
> > > package org.apache.http.examples.client;
> > >
> > > import java.io.File;
> > >
&

Re: apache httpclient

2019-09-06 Thread Somshekar C Kadam
Hi Yossi and Bernd,

Seems other issue path are all proper

somshekar@celsys041:~$ java org.apache.http.examples.client.ClientCustomSSL
Error: A JNI error has occurred, please check your installation and try
again
Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/http/ssl/TrustStrategy
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException:
org.apache.http.ssl.TrustStrategy
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more

Regards
Somshekar C Kadam
9036660538


On Thu, Sep 5, 2019 at 9:17 PM Somshekar C Kadam 
wrote:

> Yes Yossi I think I need to do that, Thanks a lot for your suggestions and
> support.
>
> Regards Somshekar
>
> On Thu, Sep 5, 2019, 8:48 PM  wrote:
>
>> Your class should also be in the classpath. Add
>> ";path/ClientCustomSSL.class" to your class path.
>> (This is basic Java stuff, unrelated to HC. Maybe you should do some Java
>> tutorial first, or if possible start using an IDE, which simplifies a lot
>> of these issues.)
>>
>> -Original Message-
>> From: Somshekar C Kadam 
>> Sent: Thursday, 5 September 2019 16:51
>> To: HttpClient User Discussion 
>> Subject: Re: apache httpclient
>>
>> Hi Yossi,
>> tried the same
>>
>> somshekar@celsys041:~$ java -classpath
>>
>> /home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpcore-4.4.11.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-osgi-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-cache-4.5.9.jar
>> org.apache.http.examples.client.ClientCustomSSL
>> Error: Could not find or load main class
>> org.apache.http.examples.client.ClientCustomSSL
>>
>> same even with sudo, not sure why am I missing naything else Sorry for
>> many mails on this
>>
>> thanks in advance
>>
>> Regards
>> Somshekar C Kadam
>> 9036660538
>>
>>
>> On Thu, Sep 5, 2019 at 6:46 PM  wrote:
>>
>> > You need to specify the full package name of the main class (in your
>> > case org.apache.http.examples.client.ClientCustomSSL).
>> >
>> > -Original Message-
>> > From: Somshekar C Kadam 
>> > Sent: Thursday, 5 September 2019 16:14
>> > To: HttpClient User Discussion 
>> > Subject: Re: apache httpclient
>> >
>> > Hi Yossi,
>> > Thanks you are right, I did put all jar files and compiled it, now it
>> > compiles successfully able to create class file.
>> >
>> > compile command
>> >
>> > javac -classpath
>> >
>> > /home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpc
>> > lient-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client
>> > -4.5.9/lib/httpcore-4.4.11.jar:/home/somshekar/akshay/java-jvms/httpco
>> > mponents-client-4.5.9/lib/httpclient-osgi-4.5.9.jar:/home/somshekar/ak
>> > shay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-cache-4.5.9.
>> > jar
>> > ClientCustomSSL.java
>> >
>> >
>> > somshekar@celsys041:~$ file ClientCustomSSL.class
>> > ClientCustomSSL.class: compiled Java class data, version 52.0 (Java
>> > 1.8)
>> >
>> >
>> > when I try to run it, it gives below error, do I have to specify the
>> > classpath at runtime also
>> >
>> > somshekar@celsys041:~$ sudo java -classpath
>> > /home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpc
>> > lient-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client
>> > -4.5.9/lib/httpcore-4.4.11.jar:/home/somshekar/akshay/java-jvms/httpco
>> > mponents-client-4.5.9/lib/httpclient-osgi-4.5.9.jar:/home/somshekar/ak
>> > shay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-cache-4.5.9.
>> > jar
>> > ClientCustomSSL
>> > Error: Could not find or load main class ClientCustomSSL
>> >
>> > thanks in advance
>> > Regards

Re: apache httpclient

2019-09-06 Thread Bernd Eckenfels
You are not specifying a classpath? TrustStrategy is part of 
httpcomponents-core.


--
http://bernd.eckenfels.net


Von: Somshekar C Kadam 
Gesendet: Freitag, September 6, 2019 10:21 AM
An: HttpClient User Discussion
Betreff: Re: apache httpclient

Hi Yossi and Bernd,

Seems other issue path are all proper

somshekar@celsys041:~$ java org.apache.http.examples.client.ClientCustomSSL
Error: A JNI error has occurred, please check your installation and try
again
Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/http/ssl/TrustStrategy
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException:
org.apache.http.ssl.TrustStrategy
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more

Regards
Somshekar C Kadam
9036660538


On Thu, Sep 5, 2019 at 9:17 PM Somshekar C Kadam 
wrote:

> Yes Yossi I think I need to do that, Thanks a lot for your suggestions and
> support.
>
> Regards Somshekar
>
> On Thu, Sep 5, 2019, 8:48 PM  wrote:
>
>> Your class should also be in the classpath. Add
>> ";path/ClientCustomSSL.class" to your class path.
>> (This is basic Java stuff, unrelated to HC. Maybe you should do some Java
>> tutorial first, or if possible start using an IDE, which simplifies a lot
>> of these issues.)
>>
>> -Original Message-
>> From: Somshekar C Kadam 
>> Sent: Thursday, 5 September 2019 16:51
>> To: HttpClient User Discussion 
>> Subject: Re: apache httpclient
>>
>> Hi Yossi,
>> tried the same
>>
>> somshekar@celsys041:~$ java -classpath
>>
>> /home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpcore-4.4.11.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-osgi-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-cache-4.5.9.jar
>> org.apache.http.examples.client.ClientCustomSSL
>> Error: Could not find or load main class
>> org.apache.http.examples.client.ClientCustomSSL
>>
>> same even with sudo, not sure why am I missing naything else Sorry for
>> many mails on this
>>
>> thanks in advance
>>
>> Regards
>> Somshekar C Kadam
>> 9036660538
>>
>>
>> On Thu, Sep 5, 2019 at 6:46 PM  wrote:
>>
>> > You need to specify the full package name of the main class (in your
>> > case org.apache.http.examples.client.ClientCustomSSL).
>> >
>> > -Original Message-
>> > From: Somshekar C Kadam 
>> > Sent: Thursday, 5 September 2019 16:14
>> > To: HttpClient User Discussion 
>> > Subject: Re: apache httpclient
>> >
>> > Hi Yossi,
>> > Thanks you are right, I did put all jar files and compiled it, now it
>> > compiles successfully able to create class file.
>> >
>> > compile command
>> >
>> > javac -classpath
>> >
>> > /home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpc
>> > lient-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client
>> > -4.5.9/lib/httpcore-4.4.11.jar:/home/somshekar/akshay/java-jvms/httpco
>> > mponents-client-4.5.9/lib/httpclient-osgi-4.5.9.jar:/home/somshekar/ak
>> > shay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-cache-4.5.9.
>> > jar
>> > ClientCustomSSL.java
>> >
>> >
>> > somshekar@celsys041:~$ file ClientCustomSSL.class
>> > ClientCustomSSL.class: compiled Java class data, version 52.0 (Java
>> > 1.8)
>> >
>> >
>> > when I try to run it, it gives below error, do I have to specify the
>> > classpath at runtime also
>> >
>> > somshekar@celsys041:~$ sudo java -classpath
>> > /home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpc
>> > lient-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client
>> > -4.5.9/lib/httpcore-4.4.11.jar:/home/somshekar/akshay/java-jvms/httpco
>> > mponents-client-4.5.9/lib/httpclient-osgi-4.5.9.jar:/ho

Re: apache httpclient

2019-09-06 Thread Somshekar C Kadam
Hi Bernd and Yossi,

I am not sure what else I need to do on this stuck
Did give the classpath while executing  as mentioned by Bernd and Yossi.

somshekar@celsys041:~$ sudo java -classpath
/home/somshekar/Downloads/httpcomponents-core-4.4.12/lib/httpcore-4.4.12.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-4.5.9.jar
ClientCustomSSL
Error: Could not find or load main class ClientCustomSSL

somshekar@celsys041:~$ sudo java -classpath
/home/somshekar/Downloads/httpcomponents-core-4.4.12/lib/httpcore-4.4.12.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-4.5.9.jar:/home/somshekar/ClientCustomSSL.class
ClientCustomSSL
Error: Could not find or load main class ClientCustomSSL

somshekar@celsys041:~$ pwd
/home/somshekar
somshekar@celsys041:~$ file ClientCustomSSL.class
ClientCustomSSL.class: compiled Java class data, version 52.0 (Java 1.8)
somshekar@celsys041:~$

Regards
Somshekar C Kadam
9036660538


On Fri, Sep 6, 2019 at 2:13 PM Bernd Eckenfels 
wrote:

> You are not specifying a classpath? TrustStrategy is part of
> httpcomponents-core.
>
>
> --
> http://bernd.eckenfels.net
>
> 
> Von: Somshekar C Kadam 
> Gesendet: Freitag, September 6, 2019 10:21 AM
> An: HttpClient User Discussion
> Betreff: Re: apache httpclient
>
> Hi Yossi and Bernd,
>
> Seems other issue path are all proper
>
> somshekar@celsys041:~$ java
> org.apache.http.examples.client.ClientCustomSSL
> Error: A JNI error has occurred, please check your installation and try
> again
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/http/ssl/TrustStrategy
> at java.lang.Class.getDeclaredMethods0(Native Method)
> at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
> at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
> at java.lang.Class.getMethod0(Class.java:3018)
> at java.lang.Class.getMethod(Class.java:1784)
> at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
> at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
> Caused by: java.lang.ClassNotFoundException:
> org.apache.http.ssl.TrustStrategy
> at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
> ... 7 more
>
> Regards
> Somshekar C Kadam
> 9036660538
>
>
> On Thu, Sep 5, 2019 at 9:17 PM Somshekar C Kadam 
> wrote:
>
> > Yes Yossi I think I need to do that, Thanks a lot for your suggestions
> and
> > support.
> >
> > Regards Somshekar
> >
> > On Thu, Sep 5, 2019, 8:48 PM  wrote:
> >
> >> Your class should also be in the classpath. Add
> >> ";path/ClientCustomSSL.class" to your class path.
> >> (This is basic Java stuff, unrelated to HC. Maybe you should do some
> Java
> >> tutorial first, or if possible start using an IDE, which simplifies a
> lot
> >> of these issues.)
> >>
> >> -Original Message-
> >> From: Somshekar C Kadam 
> >> Sent: Thursday, 5 September 2019 16:51
> >> To: HttpClient User Discussion 
> >> Subject: Re: apache httpclient
> >>
> >> Hi Yossi,
> >> tried the same
> >>
> >> somshekar@celsys041:~$ java -classpath
> >>
> >>
> /home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpcore-4.4.11.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-osgi-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-cache-4.5.9.jar
> >> org.apache.http.examples.client.ClientCustomSSL
> >> Error: Could not find or load main class
> >> org.apache.http.examples.client.ClientCustomSSL
> >>
> >> same even with sudo, not sure why am I missing naything else Sorry for
> >> many mails on this
> >>
> >> thanks in advance
> >>
> >> Regards
> >> Somshekar C Kadam
> >> 9036660538
> >>
> >>
> >> On Thu, Sep 5, 2019 at 6:46 PM  wrote:
> >>
> >> > You need to specify the full package name of the main class (in your
> >> > case org.apache.http.examples.client.ClientCustomSSL).
> >> >
> >> > -Original Message-
> >> > From: Somshekar C Kadam 
> >> > Sent: Thursday, 5 September 2019 16:14
> >> > To: HttpClient User Discussion 
> >> > Subject: Re: apache httpclient

Re: apache httpclient

2019-09-06 Thread Somshekar C Kadam
Also I tried with higher version httpcomponents-client-5.0-beta5 version
with example given in it.
Same result.
Regards
Somshekar C Kadam
9036660538


On Fri, Sep 6, 2019 at 4:59 PM Somshekar C Kadam 
wrote:

> Hi Bernd and Yossi,
>
> I am not sure what else I need to do on this stuck
> Did give the classpath while executing  as mentioned by Bernd and Yossi.
>
> somshekar@celsys041:~$ sudo java -classpath
> /home/somshekar/Downloads/httpcomponents-core-4.4.12/lib/httpcore-4.4.12.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-4.5.9.jar
> ClientCustomSSL
> Error: Could not find or load main class ClientCustomSSL
>
> somshekar@celsys041:~$ sudo java -classpath
> /home/somshekar/Downloads/httpcomponents-core-4.4.12/lib/httpcore-4.4.12.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-4.5.9.jar:/home/somshekar/ClientCustomSSL.class
> ClientCustomSSL
> Error: Could not find or load main class ClientCustomSSL
>
> somshekar@celsys041:~$ pwd
> /home/somshekar
> somshekar@celsys041:~$ file ClientCustomSSL.class
> ClientCustomSSL.class: compiled Java class data, version 52.0 (Java 1.8)
> somshekar@celsys041:~$
>
> Regards
> Somshekar C Kadam
> 9036660538
>
>
> On Fri, Sep 6, 2019 at 2:13 PM Bernd Eckenfels 
> wrote:
>
>> You are not specifying a classpath? TrustStrategy is part of
>> httpcomponents-core.
>>
>>
>> --
>> http://bernd.eckenfels.net
>>
>> ________
>> Von: Somshekar C Kadam 
>> Gesendet: Freitag, September 6, 2019 10:21 AM
>> An: HttpClient User Discussion
>> Betreff: Re: apache httpclient
>>
>> Hi Yossi and Bernd,
>>
>> Seems other issue path are all proper
>>
>> somshekar@celsys041:~$ java
>> org.apache.http.examples.client.ClientCustomSSL
>> Error: A JNI error has occurred, please check your installation and try
>> again
>> Exception in thread "main" java.lang.NoClassDefFoundError:
>> org/apache/http/ssl/TrustStrategy
>> at java.lang.Class.getDeclaredMethods0(Native Method)
>> at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
>> at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
>> at java.lang.Class.getMethod0(Class.java:3018)
>> at java.lang.Class.getMethod(Class.java:1784)
>> at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
>> at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
>> Caused by: java.lang.ClassNotFoundException:
>> org.apache.http.ssl.TrustStrategy
>> at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
>> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
>> ... 7 more
>>
>> Regards
>> Somshekar C Kadam
>> 9036660538
>>
>>
>> On Thu, Sep 5, 2019 at 9:17 PM Somshekar C Kadam 
>> wrote:
>>
>> > Yes Yossi I think I need to do that, Thanks a lot for your suggestions
>> and
>> > support.
>> >
>> > Regards Somshekar
>> >
>> > On Thu, Sep 5, 2019, 8:48 PM  wrote:
>> >
>> >> Your class should also be in the classpath. Add
>> >> ";path/ClientCustomSSL.class" to your class path.
>> >> (This is basic Java stuff, unrelated to HC. Maybe you should do some
>> Java
>> >> tutorial first, or if possible start using an IDE, which simplifies a
>> lot
>> >> of these issues.)
>> >>
>> >> -Original Message-
>> >> From: Somshekar C Kadam 
>> >> Sent: Thursday, 5 September 2019 16:51
>> >> To: HttpClient User Discussion 
>> >> Subject: Re: apache httpclient
>> >>
>> >> Hi Yossi,
>> >> tried the same
>> >>
>> >> somshekar@celsys041:~$ java -classpath
>> >>
>> >>
>> /home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpcore-4.4.11.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-osgi-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-cache-4.5.9.jar
>> >> org.apache.http.examples.client.ClientCustomSSL
>> >> Error: Could not find or load main class
>> >> org.apache.http.examples.client.ClientCustomSSL
>> >>
>> >> same even with sudo, not sure why am I missing naything else Sorry for
>> >> many ma

Re: apache httpclient

2019-09-06 Thread Bernd Eckenfels
You need to specify the classpath and the full class name (including package).

--
https://Bernd.eckenfels.net


Von: Somshekar C Kadam 
Gesendet: Freitag, September 6, 2019 1:29 PM
An: HttpClient User Discussion
Betreff: Re: apache httpclient

Hi Bernd and Yossi,

I am not sure what else I need to do on this stuck
Did give the classpath while executing as mentioned by Bernd and Yossi.

somshekar@celsys041:~$ sudo java -classpath
/home/somshekar/Downloads/httpcomponents-core-4.4.12/lib/httpcore-4.4.12.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-4.5.9.jar
ClientCustomSSL
Error: Could not find or load main class ClientCustomSSL

somshekar@celsys041:~$ sudo java -classpath
/home/somshekar/Downloads/httpcomponents-core-4.4.12/lib/httpcore-4.4.12.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-4.5.9.jar:/home/somshekar/ClientCustomSSL.class
ClientCustomSSL
Error: Could not find or load main class ClientCustomSSL

somshekar@celsys041:~$ pwd
/home/somshekar
somshekar@celsys041:~$ file ClientCustomSSL.class
ClientCustomSSL.class: compiled Java class data, version 52.0 (Java 1.8)
somshekar@celsys041:~$

Regards
Somshekar C Kadam
9036660538


On Fri, Sep 6, 2019 at 2:13 PM Bernd Eckenfels 
wrote:

> You are not specifying a classpath? TrustStrategy is part of
> httpcomponents-core.
>
>
> --
> http://bernd.eckenfels.net
>
> 
> Von: Somshekar C Kadam 
> Gesendet: Freitag, September 6, 2019 10:21 AM
> An: HttpClient User Discussion
> Betreff: Re: apache httpclient
>
> Hi Yossi and Bernd,
>
> Seems other issue path are all proper
>
> somshekar@celsys041:~$ java
> org.apache.http.examples.client.ClientCustomSSL
> Error: A JNI error has occurred, please check your installation and try
> again
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/http/ssl/TrustStrategy
> at java.lang.Class.getDeclaredMethods0(Native Method)
> at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
> at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
> at java.lang.Class.getMethod0(Class.java:3018)
> at java.lang.Class.getMethod(Class.java:1784)
> at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
> at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
> Caused by: java.lang.ClassNotFoundException:
> org.apache.http.ssl.TrustStrategy
> at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
> ... 7 more
>
> Regards
> Somshekar C Kadam
> 9036660538
>
>
> On Thu, Sep 5, 2019 at 9:17 PM Somshekar C Kadam 
> wrote:
>
> > Yes Yossi I think I need to do that, Thanks a lot for your suggestions
> and
> > support.
> >
> > Regards Somshekar
> >
> > On Thu, Sep 5, 2019, 8:48 PM  wrote:
> >
> >> Your class should also be in the classpath. Add
> >> ";path/ClientCustomSSL.class" to your class path.
> >> (This is basic Java stuff, unrelated to HC. Maybe you should do some
> Java
> >> tutorial first, or if possible start using an IDE, which simplifies a
> lot
> >> of these issues.)
> >>
> >> -Original Message-
> >> From: Somshekar C Kadam 
> >> Sent: Thursday, 5 September 2019 16:51
> >> To: HttpClient User Discussion 
> >> Subject: Re: apache httpclient
> >>
> >> Hi Yossi,
> >> tried the same
> >>
> >> somshekar@celsys041:~$ java -classpath
> >>
> >>
> /home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpcore-4.4.11.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-osgi-4.5.9.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-cache-4.5.9.jar
> >> org.apache.http.examples.client.ClientCustomSSL
> >> Error: Could not find or load main class
> >> org.apache.http.examples.client.ClientCustomSSL
> >>
> >> same even with sudo, not sure why am I missing naything else Sorry for
> >> many mails on this
> >>
> >> thanks in advance
> >>
> >> Regards
> >> Somshekar C Kadam
> >> 9036660538
> >>
> >>
> >> On Thu, Sep 5, 2019 at 6:46 PM  wrote:
> >>
> >> > You need to specify the full package name of the main class (in your
> >> > case org.apache.http.examples.client.Cli

Re: apache httpclient

2019-09-12 Thread Somshekar C Kadam
Hi Bernd

Thanks for the information, its now able to load truststrategy class seen
in verbose logs, now facing  Exception in thread "main"
java.io.FileNotFoundException: my.keystore (No such file or directory)
issue, if you have any suggestions.

thanks in advance
somshekar@celsys041:~$ sudo java -classpath
.:/home/somshekar/Downloads/httpcomponents-client-4.5.10/lib/commons-codec-1.11.jar:/home/somshekar/Downloads/httpcomponents-client-4.5.10/lib/commons-logging-1.2.jar:/home/somshekar/Downloads/httpcomponents-client-4.5.10/lib/fluent-hc-4.5.10.jar:/home/somshekar/Downloads/httpcomponents-client-4.5.10/lib/httpclient-4.5.10.jar:/home/somshekar/Downloads/httpcomponents-client-4.5.10/lib/httpclient-cache-4.5.10.jar:/home/somshekar/Downloads/httpcomponents-client-4.5.10/lib/httpclient-osgi-4.5.10.jar:httpclient-win-4.5.10.jar:/home/somshekar/Downloads/httpcomponents-client-4.5.10/lib/httpcore-4.4.12.jar:httpmime-4.5.10.jar:/home/somshekar/Downloads/httpcomponents-client-4.5.10/lib/jna-4.5.2.jar:/home/somshekar/Downloads/httpcomponents-client-4.5.10/lib/jna-platform-4.5.2.jar
 org.apache.http.examples.client.ClientCustomSSL
Exception in thread "main" java.io.FileNotFoundException: my.keystore (No
such file or directory)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.(FileInputStream.java:138)
at
org.apache.http.ssl.SSLContextBuilder.loadTrustMaterial(SSLContextBuilder.java:253)
at
org.apache.http.examples.client.ClientCustomSSL.main(ClientCustomSSL.java:52)


Regards
Somshekar C Kadam
9036660538


On Fri, Sep 6, 2019 at 11:29 PM Bernd Eckenfels 
wrote:

> You need to specify the classpath and the full class name (including
> package).
>
> --
> https://Bernd.eckenfels.net
>
> 
> Von: Somshekar C Kadam 
> Gesendet: Freitag, September 6, 2019 1:29 PM
> An: HttpClient User Discussion
> Betreff: Re: apache httpclient
>
> Hi Bernd and Yossi,
>
> I am not sure what else I need to do on this stuck
> Did give the classpath while executing as mentioned by Bernd and Yossi.
>
> somshekar@celsys041:~$ sudo java -classpath
>
> /home/somshekar/Downloads/httpcomponents-core-4.4.12/lib/httpcore-4.4.12.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-4.5.9.jar
> ClientCustomSSL
> Error: Could not find or load main class ClientCustomSSL
>
> somshekar@celsys041:~$ sudo java -classpath
>
> /home/somshekar/Downloads/httpcomponents-core-4.4.12/lib/httpcore-4.4.12.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-4.5.9.jar:/home/somshekar/ClientCustomSSL.class
> ClientCustomSSL
> Error: Could not find or load main class ClientCustomSSL
>
> somshekar@celsys041:~$ pwd
> /home/somshekar
> somshekar@celsys041:~$ file ClientCustomSSL.class
> ClientCustomSSL.class: compiled Java class data, version 52.0 (Java 1.8)
> somshekar@celsys041:~$
>
> Regards
> Somshekar C Kadam
> 9036660538
>
>
> On Fri, Sep 6, 2019 at 2:13 PM Bernd Eckenfels 
> wrote:
>
> > You are not specifying a classpath? TrustStrategy is part of
> > httpcomponents-core.
> >
> >
> > --
> > http://bernd.eckenfels.net
> >
> > 
> > Von: Somshekar C Kadam 
> > Gesendet: Freitag, September 6, 2019 10:21 AM
> > An: HttpClient User Discussion
> > Betreff: Re: apache httpclient
> >
> > Hi Yossi and Bernd,
> >
> > Seems other issue path are all proper
> >
> > somshekar@celsys041:~$ java
> > org.apache.http.examples.client.ClientCustomSSL
> > Error: A JNI error has occurred, please check your installation and try
> > again
> > Exception in thread "main" java.lang.NoClassDefFoundError:
> > org/apache/http/ssl/TrustStrategy
> > at java.lang.Class.getDeclaredMethods0(Native Method)
> > at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
> > at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
> > at java.lang.Class.getMethod0(Class.java:3018)
> > at java.lang.Class.getMethod(Class.java:1784)
> > at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
> > at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
> > Caused by: java.lang.ClassNotFoundException:
> > org.apache.http.ssl.TrustStrategy
> > at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
> > at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
> > at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
> > at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
> > ... 7 more
> >
> > Regards
> > Somshekar C Kadam
> > 9036660538
> >
> 

Re: apache httpclient

2019-09-12 Thread Bernd Eckenfels
Hello,

The sample code expects a truststore file named my.keystore in the current 
runtime directory with password „nopassword“, you need to provide one it seems. 
I guess if you use official certificates you don’t need that part of the 
customization.

The Java keytool command can be used to import certificates into new keystore 
files.

BTW it might be easier to hire someone with Java experience.

Gruß
Bernd

--
https://Bernd.eckenfels.net


Von: Somshekar C Kadam 
Gesendet: Donnerstag, September 12, 2019 1:21 PM
An: HttpClient User Discussion
Betreff: Re: apache httpclient

Hi Bernd

Thanks for the information, its now able to load truststrategy class seen
in verbose logs, now facing Exception in thread "main"
java.io.FileNotFoundException: my.keystore (No such file or directory)
issue, if you have any suggestions.

thanks in advance
somshekar@celsys041:~$ sudo java -classpath
.:/home/somshekar/Downloads/httpcomponents-client-4.5.10/lib/commons-codec-1.11.jar:/home/somshekar/Downloads/httpcomponents-client-4.5.10/lib/commons-logging-1.2.jar:/home/somshekar/Downloads/httpcomponents-client-4.5.10/lib/fluent-hc-4.5.10.jar:/home/somshekar/Downloads/httpcomponents-client-4.5.10/lib/httpclient-4.5.10.jar:/home/somshekar/Downloads/httpcomponents-client-4.5.10/lib/httpclient-cache-4.5.10.jar:/home/somshekar/Downloads/httpcomponents-client-4.5.10/lib/httpclient-osgi-4.5.10.jar:httpclient-win-4.5.10.jar:/home/somshekar/Downloads/httpcomponents-client-4.5.10/lib/httpcore-4.4.12.jar:httpmime-4.5.10.jar:/home/somshekar/Downloads/httpcomponents-client-4.5.10/lib/jna-4.5.2.jar:/home/somshekar/Downloads/httpcomponents-client-4.5.10/lib/jna-platform-4.5.2.jar
org.apache.http.examples.client.ClientCustomSSL
Exception in thread "main" java.io.FileNotFoundException: my.keystore (No
such file or directory)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.(FileInputStream.java:138)
at
org.apache.http.ssl.SSLContextBuilder.loadTrustMaterial(SSLContextBuilder.java:253)
at
org.apache.http.examples.client.ClientCustomSSL.main(ClientCustomSSL.java:52)


Regards
Somshekar C Kadam
9036660538


On Fri, Sep 6, 2019 at 11:29 PM Bernd Eckenfels 
wrote:

> You need to specify the classpath and the full class name (including
> package).
>
> --
> https://Bernd.eckenfels.net
>
> 
> Von: Somshekar C Kadam 
> Gesendet: Freitag, September 6, 2019 1:29 PM
> An: HttpClient User Discussion
> Betreff: Re: apache httpclient
>
> Hi Bernd and Yossi,
>
> I am not sure what else I need to do on this stuck
> Did give the classpath while executing as mentioned by Bernd and Yossi.
>
> somshekar@celsys041:~$ sudo java -classpath
>
> /home/somshekar/Downloads/httpcomponents-core-4.4.12/lib/httpcore-4.4.12.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-4.5.9.jar
> ClientCustomSSL
> Error: Could not find or load main class ClientCustomSSL
>
> somshekar@celsys041:~$ sudo java -classpath
>
> /home/somshekar/Downloads/httpcomponents-core-4.4.12/lib/httpcore-4.4.12.jar:/home/somshekar/akshay/java-jvms/httpcomponents-client-4.5.9/lib/httpclient-4.5.9.jar:/home/somshekar/ClientCustomSSL.class
> ClientCustomSSL
> Error: Could not find or load main class ClientCustomSSL
>
> somshekar@celsys041:~$ pwd
> /home/somshekar
> somshekar@celsys041:~$ file ClientCustomSSL.class
> ClientCustomSSL.class: compiled Java class data, version 52.0 (Java 1.8)
> somshekar@celsys041:~$
>
> Regards
> Somshekar C Kadam
> 9036660538
>
>
> On Fri, Sep 6, 2019 at 2:13 PM Bernd Eckenfels 
> wrote:
>
> > You are not specifying a classpath? TrustStrategy is part of
> > httpcomponents-core.
> >
> >
> > --
> > http://bernd.eckenfels.net
> >
> > 
> > Von: Somshekar C Kadam 
> > Gesendet: Freitag, September 6, 2019 10:21 AM
> > An: HttpClient User Discussion
> > Betreff: Re: apache httpclient
> >
> > Hi Yossi and Bernd,
> >
> > Seems other issue path are all proper
> >
> > somshekar@celsys041:~$ java
> > org.apache.http.examples.client.ClientCustomSSL
> > Error: A JNI error has occurred, please check your installation and try
> > again
> > Exception in thread "main" java.lang.NoClassDefFoundError:
> > org/apache/http/ssl/TrustStrategy
> > at java.lang.Class.getDeclaredMethods0(Native Method)
> > at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
> > at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
> > at java.lang.Class.getMethod0(Class.java:3018)
> > at java.lang.Class.getMethod(Class.java:1784)
> > at sun.launcher.LauncherHelper

Re: Apache httpclient read timeout

2010-02-03 Thread Oleg Kalnichevski
On Mon, 2010-02-01 at 17:23 -0800, Learn Learn wrote:
> Hi,
> 
> We have an application on Servicemix that uses ApacheHTTPCLient within it to
> handle http based communication. In our flows, we have defined http
> endpoints with a socket timeout of 30 seconds and this usually works except
> for the case where we establish a connection with the supplier and the
> response from the supplier is very very slow. We have seen that such
> responses could come after 120 seconds eventhough the socket timeout is set
> to 30 seconds.

Vijay,

This is perfectly normal. As long as the connection keeps on sending
more packets every 30 seconds, the socket timeout will not fire.

>  Is there an option to set a different timeout like a read
> timeout to handle such situations? Any help will be greatly appreciated.
> 

There is no such parameter. It is up to the consumer of the response
InputStreram to control the timeout value on that connection.

Oleg 


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



Re: Apache httpclient read timeout

2010-02-03 Thread Learn Learn

Oleg,

That's right, but is there a way I can do a "request" timeout? Any option in
HTTPCLient that would abort a request after a time interval elapses? (time
interval defined by the timeout)
-- 
View this message in context: 
http://old.nabble.com/Apache-httpclient-read-timeout-tp27414268p27444781.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



Re: Apache httpclient read timeout

2010-02-03 Thread Oleg Kalnichevski

Learn Learn wrote:

Oleg,

That's right, but is there a way I can do a "request" timeout? Any option in
HTTPCLient that would abort a request after a time interval elapses? (time
interval defined by the timeout)


No, there is no such option.

Oleg

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



Re: Apache httpclient read timeout

2010-02-17 Thread Ken Krugler
FWIW, you could take a look at the SimpleHttpFetcher class in the Bixo  
project.


This supports a "minimum response rate" config setting, which will  
abort a request if the average response rate drops below a threshold.


-- Ken

On Feb 3, 2010, at 2:40pm, Learn Learn wrote:



Oleg,

That's right, but is there a way I can do a "request" timeout? Any  
option in
HTTPCLient that would abort a request after a time interval elapses?  
(time

interval defined by the timeout)
--
View this message in context: 
http://old.nabble.com/Apache-httpclient-read-timeout-tp27414268p27444781.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




Ken Krugler
+1 530-210-6378
http://bixolabs.com
e l a s t i c   w e b   m i n i n g





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



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


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

2016-05-11 Thread Oleg Kalnichevski
On Wed, 2016-05-11 at 15:52 +0100, 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.

Baratali

What version of HttpClient are you using? It looks like something fairly
old. 

Oleg



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



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

2016-05-11 Thread ecki
Hello,

Using TCP keepalive wont help you with default OS settings, it would not start 
to send them in the first 20 idle minutes. You could configure the host to do 
it quicker but its not something you can portably configure from Java. Besides 
not all statefull filters honor it as beeing non-idle. An alternative would be 
to send 0-byte HTTP (content transfer) chunks from the server. 

Gruss
Bernd
-- 
http://bernd.eckenfels.net

-Original Message-
From: Oleg Kalnichevski 
To: HttpClient User Discussion 
Sent: Mi., 11 Mai 2016 18:46
Subject: Re: Apache HttpClient TCP Keep-Alive (socket keep-alive)

On Wed, 2016-05-11 at 15:52 +0100, 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.

Baratali

What version of HttpClient are you using? It looks like something fairly
old. 

Oleg



-
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



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

2016-05-12 Thread Baratali Izmailov
Hello. Thanks for the quick response.

> Is there any way you can turn this into 2 requests?
For now we cannot split this into 2 HTTP requests, because we have to
change client-server protocol communication and re-implement some parts of
our application, which will take much time.
I understand that it is not that effective to keep connection open too
long, but it's only simple solution I see for now.

> What version of HttpClient are you using? It looks like something fairly
old.
It is 4.2.2. Actually I use Spring 3.2.1 httpInvoker which uses
DefaultHttpClient.

> Using TCP keepalive wont help you with default OS settings, it would not
start to send them in the first 20 idle minutes.
Can I configure Apache httpd server to do this (set keep-alive timeouts)?

Thanks,
Baratali.


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

2016-05-12 Thread Oleg Kalnichevski
On Thu, 2016-05-12 at 09:23 +0100, Baratali Izmailov wrote:
> Hello. Thanks for the quick response.
> 
> > Is there any way you can turn this into 2 requests?
> For now we cannot split this into 2 HTTP requests, because we have to
> change client-server protocol communication and re-implement some parts of
> our application, which will take much time.
> I understand that it is not that effective to keep connection open too
> long, but it's only simple solution I see for now.
> 
> > What version of HttpClient are you using? It looks like something fairly
> old.
> It is 4.2.2. Actually I use Spring 3.2.1 httpInvoker which uses
> DefaultHttpClient.
> 

Please consider upgrading. I am not entirely sure if HC 4.2 supports TCP
keepalive setting.

Oleg

> > Using TCP keepalive wont help you with default OS settings, it would not
> start to send them in the first 20 idle minutes.
> Can I configure Apache httpd server to do this (set keep-alive timeouts)?
> 
> Thanks,
> Baratali.



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



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

2016-05-12 Thread Baratali Izmailov
> Please consider upgrading. I am not entirely sure if HC 4.2 supports TCP 
> keepalive
setting.

Unfortunately, to upgrade HC we need to upgrade Spring to the latest
version which requires Java 8. But, we cannot force our clients to use Java
8 yet.
However, I don't see SO_KEEPALIVE parameter in the lastest Apache HC
javadocs in "The following parameters can be used to customize the behavior
of this class:" section:
https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/client/DefaultHttpClient.html

Could you please show me example how to set SO_KEEPALIVE parameter in new
versions of Apache HC?

Thanks,
Baratali Izmailov.

On 12 May 2016 at 09:53, Oleg Kalnichevski  wrote:

> On Thu, 2016-05-12 at 09:23 +0100, Baratali Izmailov wrote:
> > Hello. Thanks for the quick response.
> >
> > > Is there any way you can turn this into 2 requests?
> > For now we cannot split this into 2 HTTP requests, because we have to
> > change client-server protocol communication and re-implement some parts
> of
> > our application, which will take much time.
> > I understand that it is not that effective to keep connection open too
> > long, but it's only simple solution I see for now.
> >
> > > What version of HttpClient are you using? It looks like something
> fairly
> > old.
> > It is 4.2.2. Actually I use Spring 3.2.1 httpInvoker which uses
> > DefaultHttpClient.
> >
>
> Please consider upgrading. I am not entirely sure if HC 4.2 supports TCP
> keepalive setting.
>
> Oleg
>
> > > Using TCP keepalive wont help you with default OS settings, it would
> not
> > start to send them in the first 20 idle minutes.
> > Can I configure Apache httpd server to do this (set keep-alive timeouts)?
> >
> > Thanks,
> > Baratali.
>
>
>
> -
> To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
> For additional commands, e-mail: httpclient-users-h...@hc.apache.org
>
>


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

2016-05-12 Thread Oleg Kalnichevski
On Thu, 2016-05-12 at 13:46 +0100, Baratali Izmailov wrote:
> > Please consider upgrading. I am not entirely sure if HC 4.2 supports TCP 
> > keepalive
> setting.
> 
> Unfortunately, to upgrade HC we need to upgrade Spring to the latest
> version which requires Java 8. But, we cannot force our clients to use Java
> 8 yet.

There is no need to upgrade Spring. You can upgrade HC dependency to
something more recent without upgrading Spring itself. 

In this case however you should pass a custom instance of HttpClient to
ClientHttpRequestFactory

https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.html#HttpComponentsClientHttpRequestFactory-org.apache.http.client.HttpClient-

> However, I don't see SO_KEEPALIVE parameter in the lastest Apache HC
> javadocs in "The following parameters can be used to customize the behavior
> of this class:" section:
> https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/client/DefaultHttpClient.html
> 
> Could you please show me example how to set SO_KEEPALIVE parameter in new
> versions of Apache HC?
> 

---
SocketConfig socketConfig = SocketConfig.custom()
.setSoKeepAlive(true)
.build();
CloseableHttpClient client = HttpClientBuilder.create()
.setDefaultSocketConfig(socketConfig)
.build();
ClientHttpRequestFactory clientfactory = new 
HttpComponentsClientHttpRequestFactory(client); 
---

Hope this helps

Oleg


> Thanks,
> Baratali Izmailov.
> 
> On 12 May 2016 at 09:53, Oleg Kalnichevski  wrote:
> 
> > On Thu, 2016-05-12 at 09:23 +0100, Baratali Izmailov wrote:
> > > Hello. Thanks for the quick response.
> > >
> > > > Is there any way you can turn this into 2 requests?
> > > For now we cannot split this into 2 HTTP requests, because we have to
> > > change client-server protocol communication and re-implement some parts
> > of
> > > our application, which will take much time.
> > > I understand that it is not that effective to keep connection open too
> > > long, but it's only simple solution I see for now.
> > >
> > > > What version of HttpClient are you using? It looks like something
> > fairly
> > > old.
> > > It is 4.2.2. Actually I use Spring 3.2.1 httpInvoker which uses
> > > DefaultHttpClient.
> > >
> >
> > Please consider upgrading. I am not entirely sure if HC 4.2 supports TCP
> > keepalive setting.
> >
> > Oleg
> >
> > > > Using TCP keepalive wont help you with default OS settings, it would
> > not
> > > start to send them in the first 20 idle minutes.
> > > Can I configure Apache httpd server to do this (set keep-alive timeouts)?
> > >
> > > Thanks,
> > > Baratali.
> >
> >
> >
> > -
> > 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



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

2016-05-18 Thread Baratali Izmailov
Thank you. I updated Apache HttpClient version as you described. However,
it didn't help, TCP KeepAlive packets were not sent between client and
server.
If correctly understand, the problem is that I cannot edit TCP KeepAlive
timouts in HttpClient or even in Apache httpd server. It works only if I
set timeouts on OS level (in Linux):
sudo sysctl -w net.ipv4.tcp_keepalive_time=60
sudo sysctl -w net.ipv4.tcp_keepalive_intvl=60
sudo sysctl -w net.ipv4.tcp_keepalive_probes=10

With such configs the server sends TCP KeepAlive packets every 60 seconds.

Thanks,
Baratali Izmailov.

On 12 May 2016 at 15:53, Oleg Kalnichevski  wrote:

> On Thu, 2016-05-12 at 13:46 +0100, Baratali Izmailov wrote:
> > > Please consider upgrading. I am not entirely sure if HC 4.2 supports
> TCP keepalive
> > setting.
> >
> > Unfortunately, to upgrade HC we need to upgrade Spring to the latest
> > version which requires Java 8. But, we cannot force our clients to use
> Java
> > 8 yet.
>
> There is no need to upgrade Spring. You can upgrade HC dependency to
> something more recent without upgrading Spring itself.
>
> In this case however you should pass a custom instance of HttpClient to
> ClientHttpRequestFactory
>
>
> https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.html#HttpComponentsClientHttpRequestFactory-org.apache.http.client.HttpClient-
>
> > However, I don't see SO_KEEPALIVE parameter in the lastest Apache HC
> > javadocs in "The following parameters can be used to customize the
> behavior
> > of this class:" section:
> >
> https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/client/DefaultHttpClient.html
> >
> > Could you please show me example how to set SO_KEEPALIVE parameter in new
> > versions of Apache HC?
> >
>
> ---
> SocketConfig socketConfig = SocketConfig.custom()
> .setSoKeepAlive(true)
> .build();
> CloseableHttpClient client = HttpClientBuilder.create()
> .setDefaultSocketConfig(socketConfig)
> .build();
> ClientHttpRequestFactory clientfactory = new
> HttpComponentsClientHttpRequestFactory(client);
> ---
>
> Hope this helps
>
> Oleg
>
>
> > Thanks,
> > Baratali Izmailov.
> >
> > On 12 May 2016 at 09:53, Oleg Kalnichevski  wrote:
> >
> > > On Thu, 2016-05-12 at 09:23 +0100, Baratali Izmailov wrote:
> > > > Hello. Thanks for the quick response.
> > > >
> > > > > Is there any way you can turn this into 2 requests?
> > > > For now we cannot split this into 2 HTTP requests, because we have to
> > > > change client-server protocol communication and re-implement some
> parts
> > > of
> > > > our application, which will take much time.
> > > > I understand that it is not that effective to keep connection open
> too
> > > > long, but it's only simple solution I see for now.
> > > >
> > > > > What version of HttpClient are you using? It looks like something
> > > fairly
> > > > old.
> > > > It is 4.2.2. Actually I use Spring 3.2.1 httpInvoker which uses
> > > > DefaultHttpClient.
> > > >
> > >
> > > Please consider upgrading. I am not entirely sure if HC 4.2 supports
> TCP
> > > keepalive setting.
> > >
> > > Oleg
> > >
> > > > > Using TCP keepalive wont help you with default OS settings, it
> would
> > > not
> > > > start to send them in the first 20 idle minutes.
> > > > Can I configure Apache httpd server to do this (set keep-alive
> timeouts)?
> > > >
> > > > Thanks,
> > > > Baratali.
> > >
> > >
> > >
> > > -
> > > 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
>
>


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

2016-05-18 Thread ecki
How do you know the keepalive packets have not been sent? Did you run a 
tcpdump? 

The socket API (java and apache) traditionally does not support to configure 
the keepalive times, they only allow to turn it on. 

BTW: still think tcp keepalives are not what you want to rely on and might not 
help to keep a connection open if an intermediate wants to be an annoyance.

Greetings
Bernd

-- 
http://bernd.eckenfels.net

-Original Message-
From: Baratali Izmailov 
To: HttpClient User Discussion 
Sent: Mi., 18 Mai 2016 12:37
Subject: Re: Apache HttpClient TCP Keep-Alive (socket keep-alive)

Thank you. I updated Apache HttpClient version as you described. However,
it didn't help, TCP KeepAlive packets were not sent between client and
server.
If correctly understand, the problem is that I cannot edit TCP KeepAlive
timouts in HttpClient or even in Apache httpd server. It works only if I
set timeouts on OS level (in Linux):
sudo sysctl -w net.ipv4.tcp_keepalive_time=60
sudo sysctl -w net.ipv4.tcp_keepalive_intvl=60
sudo sysctl -w net.ipv4.tcp_keepalive_probes=10

With such configs the server sends TCP KeepAlive packets every 60 seconds.

Thanks,
Baratali Izmailov.

On 12 May 2016 at 15:53, Oleg Kalnichevski  wrote:

> On Thu, 2016-05-12 at 13:46 +0100, Baratali Izmailov wrote:
> > > Please consider upgrading. I am not entirely sure if HC 4.2 supports
> TCP keepalive
> > setting.
> >
> > Unfortunately, to upgrade HC we need to upgrade Spring to the latest
> > version which requires Java 8. But, we cannot force our clients to use
> Java
> > 8 yet.
>
> There is no need to upgrade Spring. You can upgrade HC dependency to
> something more recent without upgrading Spring itself.
>
> In this case however you should pass a custom instance of HttpClient to
> ClientHttpRequestFactory
>
>
> https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.html#HttpComponentsClientHttpRequestFactory-org.apache.http.client.HttpClient-
>
> > However, I don't see SO_KEEPALIVE parameter in the lastest Apache HC
> > javadocs in "The following parameters can be used to customize the
> behavior
> > of this class:" section:
> >
> https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/client/DefaultHttpClient.html
> >
> > Could you please show me example how to set SO_KEEPALIVE parameter in new
> > versions of Apache HC?
> >
>
> ---
> SocketConfig socketConfig = SocketConfig.custom()
> .setSoKeepAlive(true)
> .build();
> CloseableHttpClient client = HttpClientBuilder.create()
> .setDefaultSocketConfig(socketConfig)
> .build();
> ClientHttpRequestFactory clientfactory = new
> HttpComponentsClientHttpRequestFactory(client);
> ---
>
> Hope this helps
>
> Oleg
>
>
> > Thanks,
> > Baratali Izmailov.
> >
> > On 12 May 2016 at 09:53, Oleg Kalnichevski  wrote:
> >
> > > On Thu, 2016-05-12 at 09:23 +0100, Baratali Izmailov wrote:
> > > > Hello. Thanks for the quick response.
> > > >
> > > > > Is there any way you can turn this into 2 requests?
> > > > For now we cannot split this into 2 HTTP requests, because we have to
> > > > change client-server protocol communication and re-implement some
> parts
> > > of
> > > > our application, which will take much time.
> > > > I understand that it is not that effective to keep connection open
> too
> > > > long, but it's only simple solution I see for now.
> > > >
> > > > > What version of HttpClient are you using? It looks like something
> > > fairly
> > > > old.
> > > > It is 4.2.2. Actually I use Spring 3.2.1 httpInvoker which uses
> > > > DefaultHttpClient.
> > > >
> > >
> > > Please consider upgrading. I am not entirely sure if HC 4.2 supports
> TCP
> > > keepalive setting.
> > >
> > > Oleg
> > >
> > > > > Using TCP keepalive wont help you with default OS settings, it
> would
> > > not
> > > > start to send them in the first 20 idle minutes.
> > > > Can I configure Apache httpd server to do this (set keep-alive
> timeouts)?
> > > >
> > > > Thanks,
> > > > Baratali.
> > >
> > >
> > >
> > > -
> > > To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
> > > For additional commands, e-mail: httpclient-users-h...@hc.apache.org
> > >
> > >

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

2016-05-19 Thread Baratali Izmailov
> How do you know the keepalive packets have not been sent? Did you run a
tcpdump?
I used Wireshark with "tcp.analysis.keep_alive ||
tcp.analysis.keep_alive_ack" filter to monitor connection between client
and server.

> The socket API (java and apache) traditionally does not support to
configure the keepalive times, they only allow to turn it on.
Yes. As I know the only way to set those timeouts is configuring Linux
parameters. By default keep-alive timeout is 2 hours which is too long :)
Some explanations:
http://stackoverflow.com/questions/1480236/does-a-tcp-socket-connection-have-a-keep-alive/33927447#33927447

Thanks,
Baratali Izmailov.

On 18 May 2016 at 20:19,  wrote:

> How do you know the keepalive packets have not been sent? Did you run a
> tcpdump?
>
> The socket API (java and apache) traditionally does not support to
> configure the keepalive times, they only allow to turn it on.
>
> BTW: still think tcp keepalives are not what you want to rely on and might
> not help to keep a connection open if an intermediate wants to be an
> annoyance.
>
> Greetings
> Bernd
>
> --
> http://bernd.eckenfels.net
>
> -Original Message-
> From: Baratali Izmailov 
> To: HttpClient User Discussion 
> Sent: Mi., 18 Mai 2016 12:37
> Subject: Re: Apache HttpClient TCP Keep-Alive (socket keep-alive)
>
> Thank you. I updated Apache HttpClient version as you described. However,
> it didn't help, TCP KeepAlive packets were not sent between client and
> server.
> If correctly understand, the problem is that I cannot edit TCP KeepAlive
> timouts in HttpClient or even in Apache httpd server. It works only if I
> set timeouts on OS level (in Linux):
> sudo sysctl -w net.ipv4.tcp_keepalive_time=60
> sudo sysctl -w net.ipv4.tcp_keepalive_intvl=60
> sudo sysctl -w net.ipv4.tcp_keepalive_probes=10
>
> With such configs the server sends TCP KeepAlive packets every 60 seconds.
>
> Thanks,
> Baratali Izmailov.
>
> On 12 May 2016 at 15:53, Oleg Kalnichevski  wrote:
>
> > On Thu, 2016-05-12 at 13:46 +0100, Baratali Izmailov wrote:
> > > > Please consider upgrading. I am not entirely sure if HC 4.2 supports
> > TCP keepalive
> > > setting.
> > >
> > > Unfortunately, to upgrade HC we need to upgrade Spring to the latest
> > > version which requires Java 8. But, we cannot force our clients to use
> > Java
> > > 8 yet.
> >
> > There is no need to upgrade Spring. You can upgrade HC dependency to
> > something more recent without upgrading Spring itself.
> >
> > In this case however you should pass a custom instance of HttpClient to
> > ClientHttpRequestFactory
> >
> >
> >
> https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.html#HttpComponentsClientHttpRequestFactory-org.apache.http.client.HttpClient-
> >
> > > However, I don't see SO_KEEPALIVE parameter in the lastest Apache HC
> > > javadocs in "The following parameters can be used to customize the
> > behavior
> > > of this class:" section:
> > >
> >
> https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/client/DefaultHttpClient.html
> > >
> > > Could you please show me example how to set SO_KEEPALIVE parameter in
> new
> > > versions of Apache HC?
> > >
> >
> > ---
> > SocketConfig socketConfig = SocketConfig.custom()
> > .setSoKeepAlive(true)
> > .build();
> > CloseableHttpClient client = HttpClientBuilder.create()
> > .setDefaultSocketConfig(socketConfig)
> > .build();
> > ClientHttpRequestFactory clientfactory = new
> > HttpComponentsClientHttpRequestFactory(client);
> > ---
> >
> > Hope this helps
> >
> > Oleg
> >
> >
> > > Thanks,
> > > Baratali Izmailov.
> > >
> > > On 12 May 2016 at 09:53, Oleg Kalnichevski  wrote:
> > >
> > > > On Thu, 2016-05-12 at 09:23 +0100, Baratali Izmailov wrote:
> > > > > Hello. Thanks for the quick response.
> > > > >
> > > > > > Is there any way you can turn this into 2 requests?
> > > > > For now we cannot split this into 2 HTTP requests, because we have
> to
> > > > > change client-server protocol communication and re-implement some
> > parts
> > > > of
> > > > > our application, which will take much time.
> > > > > I understand that it is not that effective to keep connection open
> > too
> > > > > long, but i

Re: Apache HttpClient include boundary in multipart/form-data

2018-02-26 Thread Bindul Bhowmik
On Mon, Feb 26, 2018 at 5:27 PM, Arya F  wrote:
> I made a post about this on Stackoverflow and never received an answer.
> Here is the link to the post
> https://stackoverflow.com/questions/48994951/apache-httpclient-include-boundary-in-multipart-form-data
>
> Here is what I am stuck on
>
> I have the following POST request which is supposed to upload a file. But I
> can not figure out how to include the boundary in the request for the
> "Content-Type" header.
>
>
> HttpPost request = new HttpPost(url);
> request.setConfig(config);
>
> StringEntity params = new StringEntity("");
>
> HttpEntity entity = MultipartEntityBuilder.create()
> .addBinaryBody("blob", file,
> ContentType.create("application/octet-stream"), "filename").build();
>
> request.addHeader("Host", "upload.twitter.com");
> request.addHeader("Connection", "keep-alive");
> request.addHeader("User-Agent", userAgent);
> request.addHeader("Content-Type",  );
> request.addHeader("Accept", "*/*");
> request.addHeader("Accept-Encoding", "gzip, deflate, br");
> request.addHeader("Accept-Language", "en-US,en;q=0.9");
> request.addHeader("Cookie", cookies);
>
> request.setEntity(entity);
> response = httpClient.execute(request);

Arya,

I am not sure why you are adding all the request headers manually.
Things like the Content-Type should be handled from the entity
automatically for you.

A simple example code is available on the site at
https://hc.apache.org/httpcomponents-client-ga/httpmime/examples/org/apache/http/examples/entity/mime/ClientMultipartFormPost.java

Bindul

>
> int responseCode = response.getStatusLine().getStatusCode();
>
> System.out.println("upload response code: " + responseCode);
>
>
>
> any idea how this is done?

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



Re: Apache HttpClient - Using custom socket factory for failover support

2008-03-24 Thread Oleg Kalnichevski

On Thu, 2008-03-20 at 22:05 -0700, Ankur Shah wrote:
> I am using httpclient to connect to a remote server. Now for each primary
> server there's also a backup failover server that i must talk to if
> connection attempts with the primary server fails. To achieve
> this what i'd ideally like to do is have HttpClient use a custom factory
> that tries to create a socket connection with the primary server and if that
> fails (or times out), it'll go about  talking to backup server (and retry a
> few times before giving up altogether).
> 
> Now, searching on the web, i did find references to a
> MultiHomeProtocolSocketFactory (that extends DefaultSocketFactory) that is
> presumably in apache contrib package. But what that does is that in the
> overriden
> createSocket method, it takes host as a param (among other thing) and then
> simply does a InetAddress.getAllByName which is not what i want. From what i
> understand this caters to a DNS based failover which is not the case here.
> 
> What i'd ideally like to do is create a factory and have a createSocket
> method that takes primary and secondary host and port as args and then tries
> both. I am not sure though how can i make HttpConnection class
> invoke my method.

Ankur,

What's the point of trying to implement the failover support on the
ProtocolSocketFactory level? What's wrong with just retrying failed
requests against a secondary server in case the primary one is
unavailable?  

Oleg


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Apache HttpClient - Using custom socket factory for failover support

2008-03-24 Thread Ankur Shah
Hi Oleg,

Thanks for the response. The server that i am running (acting as a client in
this particular case) is working with multiple servers (hosting different
webservices) with each having a primary and a failover pair. From this
perspective the thought was that rather than having different classes (all
having their own business logic around invoking the service) handle the
connection failed attempt, somehow have some central code that attempts to
connect to the primary and fails over to the backup. I also wanted to make
sure that in case of a connection failure with primary, a new pool is
established against the backup server.

>From this perspective, an after thought that I had was this. I was going to
extend the MultiThreadedHttpConnectionManager and have a failover capable
connection manager. In there, i was thinking about exposing a method (or a
new constructor) that allows backup host and ports to be added. This manager
will cache a map of primary and backup server. In the overriden
getConnectionWithTimeout method, i'd have super return me a connection that
i'll check and make sure that is valid and if not, i'll go to my cache, get
the backup host config and open up a connection to that.

Let me know if you think this would be a good idea or not.

Ankur

On Mon, Mar 24, 2008 at 12:47 PM, Oleg Kalnichevski <[EMAIL PROTECTED]>
wrote:

>
> On Thu, 2008-03-20 at 22:05 -0700, Ankur Shah wrote:
> > I am using httpclient to connect to a remote server. Now for each
> primary
> > server there's also a backup failover server that i must talk to if
> > connection attempts with the primary server fails. To achieve
> > this what i'd ideally like to do is have HttpClient use a custom factory
> > that tries to create a socket connection with the primary server and if
> that
> > fails (or times out), it'll go about  talking to backup server (and
> retry a
> > few times before giving up altogether).
> >
> > Now, searching on the web, i did find references to a
> > MultiHomeProtocolSocketFactory (that extends DefaultSocketFactory) that
> is
> > presumably in apache contrib package. But what that does is that in the
> > overriden
> > createSocket method, it takes host as a param (among other thing) and
> then
> > simply does a InetAddress.getAllByName which is not what i want. From
> what i
> > understand this caters to a DNS based failover which is not the case
> here.
> >
> > What i'd ideally like to do is create a factory and have a createSocket
> > method that takes primary and secondary host and port as args and then
> tries
> > both. I am not sure though how can i make HttpConnection class
> > invoke my method.
>
> Ankur,
>
> What's the point of trying to implement the failover support on the
> ProtocolSocketFactory level? What's wrong with just retrying failed
> requests against a secondary server in case the primary one is
> unavailable?
>
> Oleg
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


Re: Apache HttpClient - Using custom socket factory for failover support

2008-03-25 Thread Oleg Kalnichevski

On Mon, 2008-03-24 at 15:46 -0700, Ankur Shah wrote:
> Hi Oleg,
> 
> Thanks for the response. The server that i am running (acting as a client in
> this particular case) is working with multiple servers (hosting different
> webservices) with each having a primary and a failover pair. From this
> perspective the thought was that rather than having different classes (all
> having their own business logic around invoking the service) handle the
> connection failed attempt, somehow have some central code that attempts to
> connect to the primary and fails over to the backup. I also wanted to make
> sure that in case of a connection failure with primary, a new pool is
> established against the backup server.
> 
> From this perspective, an after thought that I had was this. I was going to
> extend the MultiThreadedHttpConnectionManager and have a failover capable
> connection manager. In there, i was thinking about exposing a method (or a
> new constructor) that allows backup host and ports to be added. This manager
> will cache a map of primary and backup server. In the overriden
> getConnectionWithTimeout method, i'd have super return me a connection that
> i'll check and make sure that is valid and if not, i'll go to my cache, get
> the backup host config and open up a connection to that.
> 
> Let me know if you think this would be a good idea or not.
> 
> Ankur
> 

Ankur

My recommendation would be to implement the fail-over support as a
service on top of HttpClient

(1) execute a request against the primary host
(2) if an exception is thrown, see whether it can be treated as
recoverable
(3) if so, mark the primary host as unavailable for a certain period
time and retry the request against the secondary host
(4) when the quarantine time elapses, mark the primary host as
potentially available
(5) repeat 

Hope this helps

Oleg


> On Mon, Mar 24, 2008 at 12:47 PM, Oleg Kalnichevski <[EMAIL PROTECTED]>
> wrote:
> 
> >
> > On Thu, 2008-03-20 at 22:05 -0700, Ankur Shah wrote:
> > > I am using httpclient to connect to a remote server. Now for each
> > primary
> > > server there's also a backup failover server that i must talk to if
> > > connection attempts with the primary server fails. To achieve
> > > this what i'd ideally like to do is have HttpClient use a custom factory
> > > that tries to create a socket connection with the primary server and if
> > that
> > > fails (or times out), it'll go about  talking to backup server (and
> > retry a
> > > few times before giving up altogether).
> > >
> > > Now, searching on the web, i did find references to a
> > > MultiHomeProtocolSocketFactory (that extends DefaultSocketFactory) that
> > is
> > > presumably in apache contrib package. But what that does is that in the
> > > overriden
> > > createSocket method, it takes host as a param (among other thing) and
> > then
> > > simply does a InetAddress.getAllByName which is not what i want. From
> > what i
> > > understand this caters to a DNS based failover which is not the case
> > here.
> > >
> > > What i'd ideally like to do is create a factory and have a createSocket
> > > method that takes primary and secondary host and port as args and then
> > tries
> > > both. I am not sure though how can i make HttpConnection class
> > > invoke my method.
> >
> > Ankur,
> >
> > What's the point of trying to implement the failover support on the
> > ProtocolSocketFactory level? What's wrong with just retrying failed
> > requests against a secondary server in case the primary one is
> > unavailable?
> >
> > Oleg
> >
> >
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Apache HttpClient - Using custom socket factory for failover support

2008-03-25 Thread Ankur Shah
Thanks oleg,

Do you see any issues in the approach that i was thinking about (and have
implemented already) other than the fact that its not very clean? Could you
elaborate a bit more on what you mean by creating service on top of
httpclient, (i understand what it'll do but just didn't know what/how should
i register that with httpclient)?

On Tue, Mar 25, 2008 at 1:10 PM, Oleg Kalnichevski <[EMAIL PROTECTED]> wrote:

>
> On Mon, 2008-03-24 at 15:46 -0700, Ankur Shah wrote:
> > Hi Oleg,
> >
> > Thanks for the response. The server that i am running (acting as a
> client in
> > this particular case) is working with multiple servers (hosting
> different
> > webservices) with each having a primary and a failover pair. From this
> > perspective the thought was that rather than having different classes
> (all
> > having their own business logic around invoking the service) handle the
> > connection failed attempt, somehow have some central code that attempts
> to
> > connect to the primary and fails over to the backup. I also wanted to
> make
> > sure that in case of a connection failure with primary, a new pool is
> > established against the backup server.
> >
> > From this perspective, an after thought that I had was this. I was going
> to
> > extend the MultiThreadedHttpConnectionManager and have a failover
> capable
> > connection manager. In there, i was thinking about exposing a method (or
> a
> > new constructor) that allows backup host and ports to be added. This
> manager
> > will cache a map of primary and backup server. In the overriden
> > getConnectionWithTimeout method, i'd have super return me a connection
> that
> > i'll check and make sure that is valid and if not, i'll go to my cache,
> get
> > the backup host config and open up a connection to that.
> >
> > Let me know if you think this would be a good idea or not.
> >
> > Ankur
> >
>
> Ankur
>
> My recommendation would be to implement the fail-over support as a
> service on top of HttpClient
>
> (1) execute a request against the primary host
> (2) if an exception is thrown, see whether it can be treated as
> recoverable
> (3) if so, mark the primary host as unavailable for a certain period
> time and retry the request against the secondary host
> (4) when the quarantine time elapses, mark the primary host as
> potentially available
> (5) repeat
>
> Hope this helps
>
> Oleg
>
>
> > On Mon, Mar 24, 2008 at 12:47 PM, Oleg Kalnichevski <[EMAIL PROTECTED]>
> > wrote:
> >
> > >
> > > On Thu, 2008-03-20 at 22:05 -0700, Ankur Shah wrote:
> > > > I am using httpclient to connect to a remote server. Now for each
> > > primary
> > > > server there's also a backup failover server that i must talk to if
> > > > connection attempts with the primary server fails. To achieve
> > > > this what i'd ideally like to do is have HttpClient use a custom
> factory
> > > > that tries to create a socket connection with the primary server and
> if
> > > that
> > > > fails (or times out), it'll go about  talking to backup server (and
> > > retry a
> > > > few times before giving up altogether).
> > > >
> > > > Now, searching on the web, i did find references to a
> > > > MultiHomeProtocolSocketFactory (that extends DefaultSocketFactory)
> that
> > > is
> > > > presumably in apache contrib package. But what that does is that in
> the
> > > > overriden
> > > > createSocket method, it takes host as a param (among other thing)
> and
> > > then
> > > > simply does a InetAddress.getAllByName which is not what i want.
> From
> > > what i
> > > > understand this caters to a DNS based failover which is not the case
> > > here.
> > > >
> > > > What i'd ideally like to do is create a factory and have a
> createSocket
> > > > method that takes primary and secondary host and port as args and
> then
> > > tries
> > > > both. I am not sure though how can i make HttpConnection class
> > > > invoke my method.
> > >
> > > Ankur,
> > >
> > > What's the point of trying to implement the failover support on the
> > > ProtocolSocketFactory level? What's wrong with just retrying failed
> > > requests against a secondary server in case the primary one is
> > > unavailable?
> > >
> > > Oleg
> > >
> > >
> > > -
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


Re: Apache HttpClient - Using custom socket factory for failover support

2008-03-25 Thread Oleg Kalnichevski

On Tue, 2008-03-25 at 14:44 -0700, Ankur Shah wrote:
> Thanks oleg,
> 
> Do you see any issues in the approach that i was thinking about (and have
> implemented already) other than the fact that its not very clean?

Ankur,

The problem is the connection manager can only catch connect timeout
exceptions, but you may also want to retry requests against the
secondary host in case of other I/O failures as well (for instance, when
the primary host is able to accept connections but is unable to process
requests)

>  Could you
> elaborate a bit more on what you mean by creating service on top of
> httpclient, (i understand what it'll do but just didn't know what/how should
> i register that with httpclient)?
> 

There's no need to register anything. Just implement whatever fail-over
logic is appropriate for you application on top of HttpClient

Oleg


> On Tue, Mar 25, 2008 at 1:10 PM, Oleg Kalnichevski <[EMAIL PROTECTED]> wrote:
> 
> >
> > On Mon, 2008-03-24 at 15:46 -0700, Ankur Shah wrote:
> > > Hi Oleg,
> > >
> > > Thanks for the response. The server that i am running (acting as a
> > client in
> > > this particular case) is working with multiple servers (hosting
> > different
> > > webservices) with each having a primary and a failover pair. From this
> > > perspective the thought was that rather than having different classes
> > (all
> > > having their own business logic around invoking the service) handle the
> > > connection failed attempt, somehow have some central code that attempts
> > to
> > > connect to the primary and fails over to the backup. I also wanted to
> > make
> > > sure that in case of a connection failure with primary, a new pool is
> > > established against the backup server.
> > >
> > > From this perspective, an after thought that I had was this. I was going
> > to
> > > extend the MultiThreadedHttpConnectionManager and have a failover
> > capable
> > > connection manager. In there, i was thinking about exposing a method (or
> > a
> > > new constructor) that allows backup host and ports to be added. This
> > manager
> > > will cache a map of primary and backup server. In the overriden
> > > getConnectionWithTimeout method, i'd have super return me a connection
> > that
> > > i'll check and make sure that is valid and if not, i'll go to my cache,
> > get
> > > the backup host config and open up a connection to that.
> > >
> > > Let me know if you think this would be a good idea or not.
> > >
> > > Ankur
> > >
> >
> > Ankur
> >
> > My recommendation would be to implement the fail-over support as a
> > service on top of HttpClient
> >
> > (1) execute a request against the primary host
> > (2) if an exception is thrown, see whether it can be treated as
> > recoverable
> > (3) if so, mark the primary host as unavailable for a certain period
> > time and retry the request against the secondary host
> > (4) when the quarantine time elapses, mark the primary host as
> > potentially available
> > (5) repeat
> >
> > Hope this helps
> >
> > Oleg
> >
> >
> > > On Mon, Mar 24, 2008 at 12:47 PM, Oleg Kalnichevski <[EMAIL PROTECTED]>
> > > wrote:
> > >
> > > >
> > > > On Thu, 2008-03-20 at 22:05 -0700, Ankur Shah wrote:
> > > > > I am using httpclient to connect to a remote server. Now for each
> > > > primary
> > > > > server there's also a backup failover server that i must talk to if
> > > > > connection attempts with the primary server fails. To achieve
> > > > > this what i'd ideally like to do is have HttpClient use a custom
> > factory
> > > > > that tries to create a socket connection with the primary server and
> > if
> > > > that
> > > > > fails (or times out), it'll go about  talking to backup server (and
> > > > retry a
> > > > > few times before giving up altogether).
> > > > >
> > > > > Now, searching on the web, i did find references to a
> > > > > MultiHomeProtocolSocketFactory (that extends DefaultSocketFactory)
> > that
> > > > is
> > > > > presumably in apache contrib package. But what that does is that in
> > the
> > > > > overriden
> > > > > createSocket method, it takes host as a param (among other thing)
> > and
> > > > then
> > > > > simply does a InetAddress.getAllByName which is not what i want.
> > From
> > > > what i
> > > > > understand this caters to a DNS based failover which is not the case
> > > > here.
> > > > >
> > > > > What i'd ideally like to do is create a factory and have a
> > createSocket
> > > > > method that takes primary and secondary host and port as args and
> > then
> > > > tries
> > > > > both. I am not sure though how can i make HttpConnection class
> > > > > invoke my method.
> > > >
> > > > Ankur,
> > > >
> > > > What's the point of trying to implement the failover support on the
> > > > ProtocolSocketFactory level? What's wrong with just retrying failed
> > > > requests against a secondary server in case the primary one is
> > > > unavailable?
> > > >
> > > > Oleg
> > > >
> > > >
> > > > -