小编mnp*_*npr的帖子

Spring WebClient reactor.netty.internal.shaded.reactor.pool.PoolAcquireTimeoutException

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

webclient reactive spring5

8
推荐指数
1
解决办法
4389
查看次数

Java 11 HttpClient Http2 流过多错误

我正在使用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 stream multiplexing http2 java-11

7
推荐指数
2
解决办法
2885
查看次数