Proxy settings in Micronaut using HttpClient (Java)

25 views Asked by At

So, the problem is, that on one of the wi-fi at work we use proxy and request to external API from my micronaut app gets refused. Internal Server Error: Connect Error: Connection refused: api.weatherapi.com/138.199...

Doing same request on another wifi without proxy works 100% fine. Also sending same request from plain Java app (with ENV variables set in run config(-Dhttp.proxyHost=aproxy.XXX.net -Dhttp.proxyPort=8080) works fine.

in Micronaut app I am using HttpClient: import io.micronaut.http.client.HttpClient; ... URI uri = UriBuilder.of(WEATHER_API_URL) .path(WEATHER_CURRENT) .queryParam("key", WEATHER_API_KEY) .queryParam("q", location) .queryParam("aqi", "no") .build();

    HttpRequest<?> request = HttpRequest.GET(uri);

    return httpClient.toBlocking().exchange(request, WeatherResponse.class);
}

I found that proxy settings can be set in application.yml like this: micronaut: http: client: proxy-address: aproxy.XXX.net:8080

but then, after sending request I get this ERROR: Internal Server Error: Connect Error: type DIRECT is not compatible with address aproxy.XXX.net/:8080

0

There are 0 answers