reactor / reactor-netty

TCP/HTTP/UDP/QUIC client/server with Reactor over Netty

Home Page:https://projectreactor.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Connection prematurely closed DURING response

abdullah-jfreaks opened this issue · comments

  @Bean("webClient")
  public WebClient buildClient(@Qualifier("getNettyHttpClientProxyConfig") HttpClient httpClient) {
    ClientHttpConnector connector = new ReactorClientHttpConnector(httpClient);
    return
        WebClient.builder()
            .clientConnector(connector)
            .codecs(clientCodecConfigurer ->
                clientCodecConfigurer
                    .defaultCodecs()
                    .maxInMemorySize(570000000))
            .build();

  }

  @Bean("getNettyHttpClientProxyConfig")
  public HttpClient getNettyHttpClientProxyConfig() {
    ConnectionProvider connectionProvider = ConnectionProvider.builder("connection-pool")
        .maxConnections(30)
        .pendingAcquireTimeout(Duration.ofMinutes(4))
        .build();
    var httpClient = HttpClient.create(connectionProvider)
        .keepAlive(false)
        .secure(sslContextSpec -> sslContextSpec.sslContext(Http11SslContextSpec.forClient())
            .handshakeTimeout(Duration.ofMinutes(4)))
        .runOn(LoopResources.create("netty-httpClient-loopResources", 1, 1024, false))
        .proxy(proxy -> proxy.type(ProxyProvider.Proxy.HTTP)
            .host(proxyHost)
            .port(proxyPort)
            .username(proxyUsername)
            .password(user -> proxyPassword)
            .connectTimeoutMillis(240_000));

    httpClient.warmup().block();
    return httpClient;
  }

Above Configuration leads to the following Exception:

reactor.netty.http.client.PrematureCloseException: Connection prematurely closed DURING response
	Suppressed: The stacktrace has been enhanced by Reactor, refer to additional information below: 
Error has been observed at the following site(s):
	*__checkpoint ⇢ Body from GET https://data-store.ripe.net/datasets/atlas-daily-dumps/2023-10-31/ntp-2023-10-31T0000.bz2 [DefaultClientResponse]
Original Stack Trace:

Kindly help me to fix this.
Thank You

@abdullah-jfreaks Please review this FAQ https://projectreactor.io/docs/netty/release/reference/index.html#faq.connection-closed
If you still cannot resolve the issue, please provide tcp dump.

@abdullah-jfreaks I'm closing this one. We can reopen it, if it is needed.