0

I am trying to access an external API from spring boots using the OpenFeign with OkHttpClient as the client.

@FeignClient(name = "CamptClient",  configuration = {FeignConfigurationProxy.class}, url = CAMPTFileConstants.EXTERNAL_BASE_URL)
public interface JSONPlaceHolderClient {

@Headers({"Content-Type: application/json"})
@PostMapping(value = "/token-auth")
Response postAuthCredentials(@RequestBody CAMPTCredentials camptCredentials);

 

This is my configuration class in which i set the proxy:

@Bean
public feign.Client feignClient() {
    OkHttpClient okHttpClient;
    Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(HOST_PROXY, PORT_PROXY));
    okHttpClient = new OkHttpClient.Builder().proxy(proxy).proxyAuthenticator(authenticator()).build();
    return new feign.okhttp.OkHttpClient(okHttpClient);
}

private okhttp3.Authenticator authenticator() {
    return (route, response) -> {
        String credential = okhttp3.Credentials.basic(username, password);
        return response.request().newBuilder()
                .header("Proxy-Authorization", credential)
                .build();
    };
}

the okhttpclient is enabled via the application.properties feign.okhttp.enabled=true

I get back a time out after some sec, without any further message.

I can access the endpoint with this curl request from the tomcat server :

curl --request POST 
     --header 'Content-Type: application/json' 
     --url 'https://xxx.api.tm.complyadvantage.com/external/token-auth' 
     --data '{"username":"xxx","password":"xxx"}' 
     -x proxy.local:8080

I have tried with all the different clients and the error is the same. I have tried with WebClient but still getting the time out. This is not a problem of changing the time out timer, for some reason the request never reaches the external API. What am i missing?

Markos Tzetzis
  • 103
  • 1
  • 12

0 Answers0