HttpClient not using proxy set in AEM | Community
Skip to main content
abhinarvekar
Level 2
January 9, 2019
Solved

HttpClient not using proxy set in AEM

  • January 9, 2019
  • 1 reply
  • 1504 views

Hello,

My application need to make a REST call to the external world.

I use Apache HttpClient to do. I expect that the call goes through proxy set in AEM, but it doesn't, it directly tries to fetch data.

I do not want to add explicit configuration for proxy in my application, it should just use default proxy set inAEM.

Any ideas how to do it?

Thanks,
Abhijeet

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Gaurav-Behl

Refer this -

HttpClient is not passing through proxy

Get the factory from OSGI itself rather than creating a custom instance of HTTPClient where you would need to read the OSGI properties on your own.

//Add the HTTP Client Builder Factory reference like below in your OSGI component.

@Reference

private HttpClientBuilderFactory httpFactory; //in your method then you can get the HTTP Client object.

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

1 reply

Gaurav-Behl
Gaurav-BehlAccepted solution
Level 10
January 9, 2019

Refer this -

HttpClient is not passing through proxy

Get the factory from OSGI itself rather than creating a custom instance of HTTPClient where you would need to read the OSGI properties on your own.

//Add the HTTP Client Builder Factory reference like below in your OSGI component.

@Reference

private HttpClientBuilderFactory httpFactory; //in your method then you can get the HTTP Client object.

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