application.yml 中的客户端设置代理如何与 Micronaut 一起使用?
How setting proxies for client in application.yml works with Micronaut?
我正在使用 Micronaut 1.1.4,我们公司正在尝试采用它。但是用 Micronaut 处理代理似乎很头疼。
我们已经尝试了简单示例中描述的低级客户端 "Bintray" link。当不涉及代理时,它工作没有任何问题。
但是如果我们在某种代理后面,这个例子就会失败:读取超时。我们尝试了建议的解决方案 here,但它不起作用。
设置为 application.yml 的代理应该如何在 Micronaut 中工作?顺便说一句,如何为客户端(声明式或低级)设置代理,因为它似乎很神秘?
编辑 1:
在测试时我遇到了这些事实:
application.yml :
---
micronaut:
application:
name: myapp
---
micronaut:
http:
client:
proxy-address: proxy:port
proxy-type: HTTP
这个仅适用于测试 类 @inject 自定义客户端,不适用于 rxhttpclient。
MyTest.java
@Inject @Client("/test") RxHttpClient localhostClient; // call through this client will failed because of how the proxy is set
@Inject CustomClient myClient; // call will succeed
使用Micronaut 1.2及以上版本解决问题
我正在使用 Micronaut 1.1.4,我们公司正在尝试采用它。但是用 Micronaut 处理代理似乎很头疼。
我们已经尝试了简单示例中描述的低级客户端 "Bintray" link。当不涉及代理时,它工作没有任何问题。
但是如果我们在某种代理后面,这个例子就会失败:读取超时。我们尝试了建议的解决方案 here,但它不起作用。
设置为 application.yml 的代理应该如何在 Micronaut 中工作?顺便说一句,如何为客户端(声明式或低级)设置代理,因为它似乎很神秘?
编辑 1:
在测试时我遇到了这些事实:
application.yml :
---
micronaut:
application:
name: myapp
---
micronaut:
http:
client:
proxy-address: proxy:port
proxy-type: HTTP
这个仅适用于测试 类 @inject 自定义客户端,不适用于 rxhttpclient。
MyTest.java
@Inject @Client("/test") RxHttpClient localhostClient; // call through this client will failed because of how the proxy is set
@Inject CustomClient myClient; // call will succeed
使用Micronaut 1.2及以上版本解决问题