netty - WebClientRequestException 与 Netty WebClient OIDC
问题描述
使用 https 连接到远程令牌端点(spring cloud oidc 授权代码流)时出现以下问题。我正在使用以下自定义 netty webClient :
private WebClient buildSslEnabledWebClient() throws Exception {
final String trustStorePath = ssl.getTrustStore();
final String trustStorePassword = ssl.getTrustStorePassword();
final KeyStore trustStore = createKeyStore(trustStorePath, trustStorePassword);
Certificate cert= trustStore.getCertificate("bas-wallet");
try {
final TrustManagerFactory trustManager = TrustManagerFactory
.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustManager.init(trustStore);
final SslContext sslContext = SslContextBuilder.forClient().trustManager(trustManager)
.build();
final HttpClient httpClient = HttpClient.create()
.tcpConfiguration(tcpClient -> tcpClient
.proxy(proxy -> proxy
.type(ProxyProvider.Proxy.HTTP)
.host("10.O.O.2")
.port(3128)))
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 50000)
.option(ChannelOption.SO_KEEPALIVE, true)
.option(EpollChannelOption.TCP_KEEPIDLE, 300)
.option(EpollChannelOption.TCP_KEEPINTVL, 60)
.option(EpollChannelOption.TCP_KEEPCNT, 8)
.secure(ssl -> (
ssl.sslContext(sslContext))
.handshakeTimeout(Duration.ofSeconds(30))
.closeNotifyFlushTimeout(Duration.ofSeconds(10))
.closeNotifyReadTimeout(Duration.ofSeconds(10)));
return WebClient.builder().clientConnector(new ReactorClientHttpConnector(httpClient)).build();
} catch (NoSuchAlgorithmException | KeyStoreException | SSLException e) {
e.printStackTrace();
throw e;
}
}
我总是收到连接超时异常:
rg.springframework.web.reactive.function.client.WebClientRequestException: Connection timed out: no further information: auth.bas.esw.esante.gouv.fr/81.80.251.57:443; nested exception is io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection timed out: no further information: auth.bas.esw.esante.gouv.fr/81.80.251.57:443
at org.springframework.web.reactive.function.client.ExchangeFunctions$DefaultExchangeFunction.lambda$wrapException$9(ExchangeFunctions.java:141) ~[spring-webflux-5.3.9.jar:5.3.9]
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Error has been observed at the following site(s):
|_ checkpoint ⇢ Request to POST https://auth.bas.esw.esante.gouv.fr/auth/realms/esante-wallet/protocol/openid-connect/token [DefaultWebClient]
|_ checkpoint ⇢ org.springframework.s
解决方案
推荐阅读
- strapi - Strapi 是否在免费套餐 AWS t3.micro 中运行?
- java - 如何创建一个whatssap按钮以向我的Android应用程序中的特定联系人发送消息?
- azure - 我可以使用自定义策略为 MFA 使用两个电子邮件地址吗?
- api-platform.com - 无法访问服务器上的管理界面
- ios - 无需调用处理程序块即可满足通知的期望
- angular - ngOnChanges 未被调用,但视图已正确更新
- angular - Angular 中连续 HTTP 请求的动态数量
- python - 对来自两个不同 JSON 文件的具有相同 ID 的对象进行分组
- javascript - Chart.js,你能覆盖图例标签框的颜色吗?
- wordpress - 如何让 WordPress 评论审核电子邮件仅发送给网站管理员