我正在使用 Spring WebClient 调用休息服务。如下所述的 post 调用代码。
Mono<ClientResponse> response = client.post()
.uri(uriBuilder -> uriBuilder.build())
.headers(httpHeaders -> httpHeaders.setAll(getHeaders()))
.body(BodyInserters.fromPublisher(Mono.just(message), String.class))
.exchange();
response.subscribe(clientResponse -> {
System.out.println(clientResponse.statusCode());
});
Run Code Online (Sandbox Code Playgroud)
在连续发布一段时间后(在 5 分钟内发布 2-3 百万个请求后),我收到以下异常。
[ parallel-3] r.c.s.Schedulers : Scheduler worker in group main failed with an uncaught exception
reactor.core.Exceptions$ErrorCallbackNotImplemented: reactor.netty.internal.shaded.reactor.pool.PoolAcquireTimeoutException: Pool#acquire(Duration) has been pending for more than the configured timeout of 45000ms
Caused by: reactor.netty.internal.shaded.reactor.pool.PoolAcquireTimeoutException: Pool#acquire(Duration) has been pending for more than the configured timeout of 45000ms
at reactor.netty.internal.shaded.reactor.pool.AbstractPool$Borrower.run(AbstractPool.java:317) ~[reactor-netty-0.9.0.RELEASE.jar!/:0.9.0.RELEASE]
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Error has been …Run Code Online (Sandbox Code Playgroud) 我正在使用HttpClientJava 11 将请求发布到 HTTP2 服务器。HttpClient 对象被创建为一个 Singleton Spring bean,如下所示。
@Bean
public HttpClient getClient() {
return HttpClient.newBuilder().version(Version.HTTP_2).executor(Executors.newFixedThreadPool(20)).followRedirects(Redirect.NORMAL)
.connectTimeout(Duration.ofSeconds(20)).build();
}
I am using the sendAsync method to send the requests asynchronously.
When I try to hit the server continuously, I am receiving the error after certain time "java.io.IOException: too many concurrent streams". I used Fixed threadpool in the Client building to try to overcome this error, but it is still giving the same error.
The Exception stack is..
java.util.concurrent.CompletionException: java.io.IOException: …Run Code Online (Sandbox Code Playgroud) concurrency ×1
http2 ×1
java-11 ×1
multiplexing ×1
reactive ×1
spring5 ×1
stream ×1
webclient ×1