Spring Web Flux WebClient:连接由对等体停止,#block终止,发生错误在以下站点发现错误

问题描述

我正在使用Spring Web Flux,Web客户端调用rest api。我收到以下错误

Oct 21 09:46:27 ql-hybrid-stg web.7d755d6967-5d7v8  Suppressed: java.lang.Exception: #block terminated with an error 
Oct 21 09:46:27 ql-hybrid-stg web.7d755d6967-5d7v8      at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:99) ~[reactor-core-3.3.2.RELEASE.jar!/:3.3.2.RELEASE] 
Oct 21 09:46:27 ql-hybrid-stg web.7d755d6967-5d7v8      ... 97 common frames omitted 
Oct 21 09:46:27 ql-hybrid-stg web.7d755d6967-5d7v8 Caused by: io.netty.channel.unix.Errors$NativeIoException: readAddress(..) Failed: Connection reset by peer 
Oct 21 09:46:27 ql-hybrid-stg web.7d755d6967-5d7v8  Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:  
Oct 21 09:46:27 ql-hybrid-stg web.7d755d6967-5d7v8 Error has been observed at the following site(s): 
Oct 21 09:46:27 ql-hybrid-stg web.7d755d6967-5d7v8  |_ checkpoint ? Request to GET https://cc-qa.app/api/matches/list/?status=current&page=0&size=100 [DefaultWebClient] 

我的网络客户端调用或我正在调用的api是否有问题? 我很困惑,因为它显示了许多错误,例如对等连接休息,#block因错误而终止。在以下站点发现了错误。 如何解决呢? 请在下面找到代码

  @Bean
  public WebClient restClient() {

    String baseurl = env.getProperty("base-url");
    int memoryLimit = Integer.parseInt(env.getProperty("webclient-buffer-size"));

    ExchangeStrategies exchangeStrategies =
        ExchangeStrategies.builder()
            .codecs(
                configurer -> configurer.defaultCodecs().maxInMemorySize(1024 * 1024 * memoryLimit))
            .build();
    return WebClient.builder()
        .exchangeStrategies(exchangeStrategies)
        .baseUrl(baseurl)
        .build();
  }

这是api调用

webClient
              .get()
              .uri("/api/matches/list/?status=current&page=0&size=100")
              .header("authorization",accesstoken)
              .retrieve()
              .bodyToMono(InfoPayload.class)
              .block();

请帮助我找到问题。预先感谢

解决方法

添加客户端连接器后问题解决。

 private ClientHttpConnector connector() {
    return new 
 ReactorClientHttpConnector(HttpClient.create(ConnectionProvider.newConnection()));
  }

WebClient.builder()
        .clientConnector(connector())
        .exchangeStrategies(exchangeStrategies)
        .baseUrl(baseurl)
        .build();