繁体   English   中英

具有代理配置的 Quarkus / Restclient

[英]Quarkus / Restclient with proxy configuration

我正在使用 quarkus 1.10.5.Final 并且需要使用 web 代理调用 web 服务。 目前我的代码使用 microprofile 客户端代理并将下面的配置放在 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

但仍然导致 RESTEASY004655: Unable to invoke request: java.net.UnknownHostException: No such host is known

我尝试使用 -Dhttp.proxyHost 和 -Dhttp.proxyPort 来测试代理,它是成功的。 问题是我不能使用 -Dparams 因为它会中断其他服务调用。

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.ZFC35FDC70D5FC69D269883A822C7A53如果我看错了请告诉我。

2021 年 5 月更新

Quarkus 2.0 支持 MicroProfile Rest 客户端 2.0。 有了它,您可以使用您提到的配置,即

# 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

或者以编程方式设置它

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

原始答案

您应该能够使用以下属性为 Quarkus Rest 客户端设置代理:

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

我刚遇到同样的问题,发现了这个问题。

升级到 MP Rest 客户端 2.0 #10520

MP-Rest-Client 2.0 在 quarkus 1.10.5 中不可用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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