reactor-netty icon indicating copy to clipboard operation
reactor-netty copied to clipboard

Connection prematurely closed DURING response

Open Aliaksie opened this issue 2 years ago • 4 comments

Possible similar to link or link

-> client send large multipart RQ -> server receive
-> check size and throw 413 -> we catch it in our error handler and return 413 with json RS -> server send completed -> server on TERMINATED check if it consume full RQ -> send new IOException("unconsumed input") and close connection

-> if the client has not yet completed processing, then it will receive an error and crash, otherwise it can complete the request smoothly (for example turn on DEBUG logs for jetty server).

Expected Behavior

the client will complete without error. I got 413 with json body.

Actual Behavior

the client does not complete consistently. I often get an error:

reactor.netty.http.client.PrematureCloseException: Connection prematurely closed DURING response
reactor.core.Exceptions$ReactiveException: reactor.netty.http.client.PrematureCloseException: Connection prematurely closed DURING response

Steps to Reproduce

check the demo-repo

Possible Solution

add .header( "Connection", "close" ) for file upload than here _generator.isPersistent() will always false

Your Environment

  • org.springframework.boot -> 3.1.5
  • jetty.version -> 11.0.16
  • reactor-netty -> 1.1.11
  • spring-boot-starter-jetty -> 3.1.4

Aliaksie avatar Oct 27 '23 10:10 Aliaksie

@Aliaksie I'm gonna work on this one.

violetagg avatar Nov 14 '23 05:11 violetagg

.retry(1)

hakusai22 avatar Jan 05 '24 09:01 hakusai22

I also have the same problem

weiyouren avatar Jan 10 '24 02:01 weiyouren

@weiyouren how do you fix this error?

yvzhu0407 avatar Mar 08 '24 09:03 yvzhu0407