spring-cloud-gateway icon indicating copy to clipboard operation
spring-cloud-gateway copied to clipboard

SpringBoot 2.6.1 Connection prematurely closed DURING response, but ServerHttpResponse already committed

Open jalr4ever opened this issue 3 years ago • 0 comments

Version

SCG deployed in ARM LIinux. JRE version: OpenJDK Runtime Environment (8.0_275-b01) (build 1.8.0_275-b01). Java VM: OpenJDK 64-Bit Server VM (25.275-b01 mixed mode linux-aarch64 compressed oops).

This is my project libarary version:

<properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>

        <spring-boot.version>2.6.1</spring-boot.version>
        <spring-cloud.version>2021.0.0</spring-cloud.version>
        <alibaba-cloud.version>2021.1</alibaba-cloud.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring-boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-alibaba-dependencies</artifactId>
                <version>${alibaba-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
    </dependencyManagement>

Bug

I use SCG as a proxy in my project. After muti request, it occurred exception occasionally, see detail below:

06-02 15:37:48.475 [reactor-http-nio-1] ERROR o.s.w.s.a.HttpWebHandlerAdapter [handleUnresolvedError] [308] - [3d6c3b8b-4] Error [reactor.netty.http.client.PrematureCloseException: Connection prematurely closed DURING response] for HTTP GET "/sssssssss/_high.tar", but ServerHttpResponse already committed (206 PARTIAL_CONTENT)
06-02 15:37:48.475 [reactor-http-nio-1] ERROR r.n.http.server.HttpServerOperations [error] [315] - [3d6c3b8b-4, L:/62.21.1.187:4520 - R:/62.21.0.0:45600] Error finishing response. Closing connection
reactor.netty.http.client.PrematureCloseException: Connection prematurely closed DURING response
        Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Error has been observed at the following site(s):
        *__checkpoint ⇢ org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain]
        *__checkpoint ⇢ HTTP GET "/sssssssss/_high.tar" [ExceptionHandlingWebHandler]
Original Stack Trace:
06-02 15:37:48.597 [reactor-http-nio-1] INFO  reactor.netty.http.server.AccessLog [info] [270] - 62.21.0.0 - - [02/Jun/2022:15:37:19 +0800] "GET /sssssssss/_high.tar HTTP/1.1" 206 104857600 29393

I have try config jvm options : -Dreactor.netty.pool.leasingStrategy=lifo

And yaml config:

spring:
  application:
    name: gateway-service
  cloud:
    gateway:
      httpclient:
        pool:
          max-idle-time: 1000

But seems like it didn't solve the issue. After that, I try to config http client pool type to fixed, it shows a serious HTTP 500 problem:

06-02 12:38:23.265 [parallel-4] ERROR o.s.b.a.w.r.e.AbstractErrorWebExceptionHandler [error] [122] - [262b0ab0-10]  500 Server Error for HTTP GET "/ssssss/_high.tar"
reactor.netty.internal.shaded.reactor.pool.PoolAcquireTimeoutException: Pool#acquire(Duration) has been pending for more than the configured timeout of 45000ms

jalr4ever avatar Jun 02 '22 08:06 jalr4ever