Reputation: 1623
I want to specify my Quarkus application (v2.8.3.Final) to use an HTTP proxy without changing any code
To attempt this I pass the -Dhttp.proxyHost
and -Dhttp.proxyPort
options to the terminal, like this:
./mvnw quarkus:dev -Dquarkus.http.host=0.0.0.0 -Dquarkus.http.port=9000 -Ddebug=9001 -Dhttp.proxyHost=localhost -Dhttp.proxyPort=6969
pom.xml
)To compare the working quarkus application (A), and the other (B) I have implemented a resource that sends a request to http://google.com
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.MediaType;
.
.
.
@GET
@Path("/google")
@Produces(MediaType.TEXT_PLAIN)
public String google() {
Client client = ClientBuilder.newClient();
return client.target("http://www.google.com")
.request(MediaType.TEXT_PLAIN)
.get()
.readEntity(String.class);
}
and I have ensured that the Quarkus versions are the same. Here is a minimal snippet from pom.xml
<properties>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
<quarkus.platform.version>2.8.3.Final</quarkus.platform.version>
</properties>
Application A successfully passes its requests to the proxy server, while B wont. Both applications are very similiar when comparing their pom.xml
files and application.properties
files. I am struggling to point out relevant differences. I would like to at least get some pointers on where I could look to fix this problem.
-Dhttp.proxyHost
and -Dhttp.proxyPort
:In application properties, specify
org.jboss.resteasy.jaxrs.client.proxy.host=http://localhost
,org.jboss.resteasy.jaxrs.client.proxy.port=6969
In application properties, specify
quarkus.rest-client.proxy-address=http://localhost:6969
,In application properties specify client/mp-rest/proxyAddress=http://localhost:6969
Other ways to pass the system properties -Dhttp.proxyHost
and -Dhttp.proxyPort
JAVA_TOOL_OPTIONS="-Dhttp.proxyHost -Dhttp.proxyPort"
Built and started a docker container with Dockerfile.jvm generated from quarkus (which is included when create a new quarkus project), then setting the env variable HTTP_PROXY=localhost:6969
.
-Dhttp.proxyHost
and -Dhttp.proxyPort
options to the application (what I have done from the beginning)System info
Upvotes: 1
Views: 1280
Reputation: 6233
Quarkus comes with two REST clients, the old classic version and the newer reactive one. The reactive client has proxy support; the classic does not advertise it. Try to switch to the reactive client.
(copied from comment)
Upvotes: 2