Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reactor.netty.http.client.PrematureCloseException: Connection prematurely closed BEFORE response #1221

Closed
CantosSong opened this issue Jul 24, 2020 · 7 comments
Assignees
Labels
status/invalid We don't feel this issue is valid

Comments

@CantosSong
Copy link

version 0.9.10.RELEASE

tomcat

server.port=9999
server.tomcat.connection-timeout=1

reactive

server.port=8888
trace=true

ab -c 100 -n1000 http://127.0.0.1:8888/test

ab -c 100 -n1000 http://127.0.0.1:8888/test1

2020-07-24 22:02:17.912  WARN 53538 --- [or-http-epoll-8] r.netty.http.client.HttpClientConnect    : [id: 0x0733a115, L:/127.0.0.1:60018 ! R:127.0.0.1/127.0.0.1:9999] The connection observed an error

reactor.netty.http.client.PrematureCloseException: Connection prematurely closed BEFORE response

sample
https://github.com/CantosSong/reactor-netty-demo-exception

@CantosSong CantosSong added status/need-triage A new issue that still need to be evaluated as a whole type/bug A general bug labels Jul 24, 2020
@CantosSong
Copy link
Author

The client needs to actively close the connection, in a certain idle time.
Or have the ability to reconnect

@CantosSong
Copy link
Author

CantosSong commented Jul 25, 2020

gateway example,the same problem exists.
ab -c 100 -n1000 http://127.0.0.1:8888/test2

from the phenomenon, for the tomcat server/nginx server timeout, it will take the initiative to disconnect, at this time the client will appear error, the client timeout setting does not take effect

reactor-netty-server example,no problem
ab -c 100 -n10000 http://127.0.0.1:8888/test4

@violetagg violetagg removed the type/bug A general bug label Jul 29, 2020
@violetagg
Copy link
Member

violetagg commented Jul 29, 2020

@CantosSong Specifying server.tomcat.connection-timeout=1 means 1ms. This means that both connectionTimeout and keepAliveTimeout will have value 1ms.
http://tomcat.apache.org/tomcat-9.0-doc/config/http.html#Standard_Implementation

keepAliveTimeout | The number of milliseconds this Connector will wait for another HTTP request before closing the connection. The default value is to use the value that has been set for the connectionTimeout attribute. Use a value of -1 to indicate no (i.e. infinite) timeout.

It happens that we have more than 1ms between the requests and Tomcat closes the connection.

If you really need that kind of timeout (1ms) then you have to configure Reactor Netty connection pool max idle timeout to be less than the Tomcat's timeout.

In any way you have always to configure the connection pool max idle timeout in accordance to what you have as a configuration on the target server.

@violetagg violetagg added the for/user-attention This issue needs user attention (feedback, rework, etc...) label Jul 29, 2020
@CantosSong
Copy link
Author

I'll test it.

maybe idle timeout needs to have a default value.

@violetagg
Copy link
Member

@CantosSong We cannot provide a default that will satisfy every use case. There might be use cases that they don't want an idle timeout.

@CantosSong
Copy link
Author

understand. thanks

@violetagg
Copy link
Member

@CantosSong I'm closing this issue. If the problem appears in Reactor Netty we can reopen it.

@violetagg violetagg added status/invalid We don't feel this issue is valid and removed for/user-attention This issue needs user attention (feedback, rework, etc...) labels Aug 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/invalid We don't feel this issue is valid
Projects
None yet
Development

No branches or pull requests

2 participants