-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
type: bugSomething isn't workingSomething isn't working
Description
Is there an existing issue for this?
- 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定义
@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
ShenYu version(s):2.5.1Debug logs
日志中没有报错信息
Anything else?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
type: bugSomething isn't workingSomething isn't working