Apache HTTP Components Proxy Configuration | Adobe Higher Education
Skip to main content
Adobe Employee
October 9, 2017
Respondido

Apache HTTP Components Proxy Configuration

  • October 9, 2017
  • 7 respostas
  • 5178 Visualizações

Hi,

I'm having an issue using Apache HTTP Components Proxy Configuration to connect to our proxy using AEM 6.3.  Using HTTPClient 3.x code I am able to access the proxy without issue using Day Commons HTTP Client 3.1.  However switching the code to org.apache.httpcomponents 4.x I am not hitting the proxy using Apache HTTP Components Proxy config using the same proxy parameters. Are there any other settings that may need to be updated to make this connection work? Is there a specific version of httpcomponents that I need to use?

Este tópico foi fechado para respostas.
Melhor resposta por -Joe-

Hi Michael,

Two things to check:

1) Make sure that you've configured your proxy settings in the Apache HTTP Components Proxy Configuration factory and not the plain PID

2) Use the HttpClientBuilderFactory (org.apache.http.osgi.services.HttpClientBuilderFactory) service to get a HttpClientBuilder

7 Respostas

-Joe-Adobe EmployeeResposta
Adobe Employee
October 9, 2017

Hi Michael,

Two things to check:

1) Make sure that you've configured your proxy settings in the Apache HTTP Components Proxy Configuration factory and not the plain PID

2) Use the HttpClientBuilderFactory (org.apache.http.osgi.services.HttpClientBuilderFactory) service to get a HttpClientBuilder

Adobe Employee
October 10, 2017

Hi Joseph,

Thanks for the response. Unfortunately I believe I've tried those with no luck. Just double-checking though on the Proxy Configuration. For factory, do you mean create a new factory configuration (+ next to configuration in italics) rather than update the primary factory?

Thanks,

Mike

Adobe Employee
October 10, 2017

Yep, that's what I mean

Adobe Employee
October 10, 2017

Can you share a screenshot of your configuration (scrub the sensitive details) and a code snippet?

Adobe Employee
October 10, 2017

Sure just running a simple HTTP GET to google:  AEM log shows the GET itself is successful.  I have a apache proxy running on localhost (screenshot attached). Viewing the apache access log I can see there is no connection through the proxy.

public class CustomStep implements WorkflowProcess

{

    

    

/** Default log. */

protected final Logger log = LoggerFactory.getLogger(this.getClass());

//Inject a HTTP Factory Service

@Reference

private HttpClientBuilderFactory httpFactory;

    

public void execute(WorkItem item, WorkflowSession wfsession,MetaDataMap args) throws WorkflowException {

        

try

{

    log.info("Here in execute method");    //ensure that the execute method is invoked  

  

  

    String url = "https://www.google.com";

    HttpClient client = httpFactory.newBuilder().build();

    HttpGet request = new HttpGet(url);

  

    HttpResponse response = client.execute(request);

  

    log.info("Response Code GET GOOGLE : "

            + response.getStatusLine().getStatusCode());

Adobe Employee
October 10, 2017

Hi Joseph,

Actually you're configuration settings did work! For some reason the apache logs with this configuration showed a 5 min delay. Thanks again for your help!

Adobe Employee
October 10, 2017

Great