简体   繁体   中英

Quarkus / Restclient with proxy configuration

I am using quarkus 1.10.5.Final and need to call web service with web proxy. Currently my code using microprofile client proxy and put below configuration in application.properties

client/mp-rest/url=https://remote.com
client/mp-rest/scope=javax.inject.Dependent
client/mp-rest/trustStore=classpath:/META-INF/resources/cacerts
client/mp-rest/connectTimeout=5000
client/mp-rest/readTimeout=5000
client/mp-rest/followRedirects=true
client/mp-rest/proxyAddress=http://proxy:8080

but still resulting RESTEASY004655: Unable to invoke request: java.net.UnknownHostException: No such host is known

I tried to use -Dhttp.proxyHost and -Dhttp.proxyPort to test the proxy and it was success. the problem is I can't use -Dparams since it will break other service calls.

this link where I got config for mp-rest/proxyAddress https://download.eclipse.org/microprofile/microprofile-rest-client-2.0-RC2/microprofile-rest-client-2.0-RC2.html but its not mentioned in https://docs.jboss.org/resteasy/docs/4.1.1.Final/userguide/html/MicroProfile_Rest_Client.html please let me know if I am looking on wrong thing.

May 2021 update

Quarkus 2.0 supports MicroProfile Rest Client 2.0. With it you can use the configuration you mention, namely

# A string value in the form of <proxyHost>:<proxyPort> that specifies the
# HTTP proxy server hostname (or IP address) and port for requests of
# this client to use.
client/mp-rest/proxyAddress=host:port

Or set it programmatically with

ProxiedClient client = RestClientBuilder.newBuilder()
                                        .baseUri(someUri)
                                        .proxyAddress("myproxy.mycompany.com", 8080)
                                        .build(ProxiedClient.class);

Original answer

You should be able to set proxy for your Quarkus Rest client with the following properties:

    org.jboss.resteasy.jaxrs.client.proxy.host
    org.jboss.resteasy.jaxrs.client.proxy.port
    org.jboss.resteasy.jaxrs.client.proxy.scheme

I just run into the same problem and found this issue.

Upgrade to MP Rest Client 2.0 #10520

MP-Rest-Client 2.0 is not available in quarkus 1.10.5.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM