【问题标题】:How setting proxies for client in application.yml works with Micronaut?在 application.yml 中为客户端设置代理如何与 Micronaut 一起使用?
【发布时间】:2019-07-18 10:05:35
【问题描述】:

我正在使用 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】:

    使用 Micronaut 1.2 及以上版本解决问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-18
      • 1970-01-01
      • 2016-12-29
      • 2013-01-17
      • 2019-12-03
      • 2016-03-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多