yuli13244 opened a new issue, #6298:
URL: https://github.com/apache/shenyu/issues/6298
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Current Behavior
shenyu代码版本:2.5.1
HttpClient配置:
shenyu.httpclient.keepAlive = true
shenyu.httpclient.pool.type = FIXED
shenyu.httpclient.pool.name = proxy
shenyu.httpclient.pool.acquireTimeout = 3000
shenyu.httpclient.pool.maxIdleTime = 10000
shenyu.httpclient.connectTimeout = 5000
shenyu.httpclient.maxInMemorySize = 10
bean定义
```java
@Bean
public HttpClient httpClient(final HttpClientProperties properties,
final ObjectProvider<LoopResources>
provider) {
// configure pool resources.
HttpClientProperties.Pool pool = properties.getPool();
ConnectionProvider connectionProvider =
buildConnectionProvider(pool);
HttpClient httpClient = HttpClient.create(connectionProvider)
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS,
properties.getConnectTimeout());
HttpClientProperties.Proxy proxy = properties.getProxy();
if (StringUtils.isNotEmpty(proxy.getHost())) {
httpClient = setHttpClientProxy(httpClient, proxy);
}
httpClient.doOnConnected(connection -> {
connection.addHandlerLast(new
IdleStateHandler(properties.getReaderIdleTime(),
properties.getWriterIdleTime(), properties.getAllIdleTime(),
TimeUnit.MILLISECONDS));
connection.addHandlerLast(new
WriteTimeoutHandler(properties.getWriteTimeout(), TimeUnit.MILLISECONDS));
connection.addHandlerLast(new
ReadTimeoutHandler(properties.getReadTimeout(), TimeUnit.MILLISECONDS));
});
final LoopResources loopResources = provider.getIfAvailable();
if (Objects.nonNull(loopResources)) {
httpClient.runOn(loopResources);
}
HttpClientProperties.Ssl ssl = properties.getSsl();
if (StringUtils.isNotEmpty(ssl.getKeyStorePath())
||
ArrayUtils.isNotEmpty(ssl.getTrustedX509CertificatesForTrustManager())
|| ssl.isUseInsecureTrustManager()) {
httpClient = httpClient.secure(sslContextSpec ->
setSsl(sslContextSpec, ssl));
}
if (properties.isWiretap()) {
httpClient = httpClient.wiretap(true);
}
// set to false, fix java.io.IOException: Connection reset by peer
// see https://github.com/reactor/reactor-netty/issues/388
return httpClient.keepAlive(properties.isKeepAlive());
}
//使用默认的webclient客户端请求业务系统,
@Configuration
@ConditionalOnProperty(name = "shenyu.httpclient.strategy", havingValue
= "webClient", matchIfMissing = true)
static class WebClientConfiguration {
/**
* Web client plugin shenyu plugin.
*
* @param httpClient the http client
* @return the shenyu plugin
*/
@Bean
public ShenyuPlugin webClientPlugin(
final HttpClientProperties properties,
final ObjectProvider<HttpClient> httpClient) {
WebClient webClient = WebClient.builder()
// fix Exceeded limit on max bytes to buffer
// detail see
https://stackoverflow.com/questions/59326351/configure-spring-codec-max-in-memory-size-when-using-reactiveelasticsearchclient
.exchangeStrategies(ExchangeStrategies.builder()
.codecs(codecs ->
codecs.defaultCodecs().maxInMemorySize(properties.getMaxInMemorySize() * 1024 *
1024))
.build())
.clientConnector(new
ReactorClientHttpConnector(Objects.requireNonNull(httpClient.getIfAvailable())))
.build();
return new WebClientPlugin(webClient);
}
}
```
### Expected Behavior
_No response_
### Steps To Reproduce
_No response_
### Environment
```markdown
ShenYu version(s):2.5.1
```
### Debug logs
日志中没有报错信息
### Anything else?
_No response_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscr...@shenyu.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org