-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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,springboot2.1.6 #1148
Comments
Please try with Greenwich.SR2 |
@spencergibb |
Please, don't use screenshots. How do we recreate the problem? |
@spencergibb I'm so sorry this is error
this is application.yml
this is my pom.xml
|
We need step by step instructions and maybe a project that recreates the problem (not pasted code). |
@spencergibb ok this is gateway project https://github.com/kinsey-jian/gateway.git this is projecthttps://github.com/kinsey-jian/cloud-k8s.git provider you should install consul In the gateway projiect you can use |
Hey @kinsey-jian. Did not check very deeply the description. It was caused by Apache through which traffic was flowing. Apache have reached the limits and was unable to handle next connection. |
Any update? I also have this issue with my project. |
Since 0.9.0.RELEASE of reactor netty there is a possibility Netty ConnectionProvider.class:
Without it as I understand connections on Netty site were not closed but kept with no limits.
when after 2 seconds not used connection is trying to be used again by Gateway. I have added commit which allows to define such maxIdleTime here #1411 but it is "waiting for triage". |
Thanks @Ziemowit. |
I saw for sure that maxIdleTime is missing for spring-gateway and it may cause the problems. Also do not know if it is your case but AFAIK on Apache level (so before Tomcat) there are also configuration which defines how long Apache keeps the connection open. It is our case because for us all traffic goes additionally via Apache. Here we are waiting for approve our commit and ship it with HOXTON release. If it does not help we will be searching further as it impacts us too :/ |
Tomcat properties have no impact since gateway uses Netty |
@spencergibb |
@ifrozenice do you have some solution about this issue? |
i argreen with @Ziemowit , but spring gateway current GA (2.2.1) can't config maxIdleTime in yml, i find the next verion can do it .so you can config your maxIdleTime in code as above. |
Closed via 069f24d |
Hello, I'm still having this problem. This is my release version
This is my routeLocator @Bean
public RouteLocator customRouteLocator(RouteLocatorBuilder builder, AuthFilter authFilter, AccessFilter accessFilter, ActuatorFilter actuatorFilter) {
return builder.routes()
.route("comments.api", p -> p
.host(host.get("api"))
.and().path("/comments/**")
.filters(f -> f.rewritePath("^/comments/(?<path>.+)", "/comments/${path}")
.filter(authFilter))
.uri(uri.get("comment")))
.route("op.api", p -> p
.host(host.get("api"))
.and().path("/op/**")
.filters(f -> f.rewritePath("^/op/(?<path>.+)", "/op/${path}")
.filter(authFilter))
.uri(uri.get("op")))
.route("campaign.api", p -> p
.host(host.get("api"))
.and().path("/campaigns/**")
.filters(f -> f.rewritePath("^/campaigns/(?<path>.+)", "/campaigns/${path}")
.filter(authFilter))
.uri(uri.get("campaign")))
.route("trevi.apply.api", p -> p
.host(host.get("api"))
.and().path("/ad/trevi/apply", "/ad/trevi/notify/installed")
.filters(f -> f.rewritePath("^/ad/trevi/(?<path>.+)", "/${path}")
.hystrix(c -> c.setName("trevi-apply-cmd").setFallbackUri("forward:/fallback/trevi")))
.uri(uri.get("trevi.apply")))
.route("trevi.track.api", p -> p
.host(host.get("api"))
.and().path("/ad/trevi/track")
.filters(f -> f.rewritePath("^/ad/trevi/(?<path>.+)", "/${path}")
.hystrix(c -> c.setName("trevi-track-cmd").setFallbackUri("forward:/fallback/trevi")))
.uri(uri.get("trevi.track")))
.route("trevi.imp.api", p -> p
.host(host.get("api"))
.and().path("/ad/trevi/reward/**")
.filters(f -> f.rewritePath("^/ad/trevi/reward/(?<path>.+)", "/reward/${path}")
.hystrix(c -> c.setName("trevi-imp-cmd").setFallbackUri("forward:/fallback/trevi")))
.uri(uri.get("trevi.imp")))
.route("iapi.api", p -> p
.host(host.get("api"))
.and().path("/ad/coupon-products/**")
.filters(f -> f.addRequestHeader("Service", "trevi")
.rewritePath("^/ad/coupon-products(?<segment>.*)", "/vp/coupon-products${segment}")
.filter(accessFilter)
.hystrix(c -> c.setName("coupon-api-cmd").setFallbackUri("forward:/fallback/coupon")))
.uri(uri.get("legacy-iapi")))
.route("iapi.dev.api", p -> p
.host(host.get("api"))
.and().path("/dev/ad/coupon-products/**")
.filters(f -> f.addRequestHeader("Service", "trevi")
.rewritePath("^/dev/ad/coupon-products(?<segment>.*)", "/vp/coupon-products${segment}")
.filter(accessFilter))
.uri(uri.get("legacy-dev-iapi")))
.route("api", p -> p
.order(999)
.host(host.get("api"))
.filters(f -> f.addRequestHeader("Service", "legacy-api")
.hystrix(c -> c.setName("legacy-cmd").setFallbackUri("forward:/fallback/legacy")))
.uri(uri.get("legacy-api")))
.build();
} This is my application.yaml spring:
profiles: sandbox
application:
name: webtoon-gateway-sandbox
cloud:
gateway:
globalcors:
cors-configurations:
'[/**]':
allowed-origins:
- "*"
allowed-methods:
- "*"
allowed-headers:
- "*"
allow-credentials: true
httpclient:
pool:
type: fixed
max-connections: 500
acquire-timeout: 75000
boot:
admin:
client:
url: http://webtoon-cloud-admin.dev.daum.net
instance:
prefer-ip: true
hystrix:
threadpool:
default:
coreSize: 128
command:
default:
execution:
isolation:
thread:
timeoutInMillseconds: 5000
circuitBreaker:
requestVolumeThreshold: 20
errorThresholdPercentage: 50
sleepWindowInMilliseconds: 5000
enabled: true Is there anything I missed? |
Please open a new issue and provide the stack trace |
@creaton60 have you tried to set the maxIdleTime property?
AFAIR by default, it is NULL so your connection will be waiting forever without closing it on the gateway and it may be closed on server site. |
@Ziemowit |
@Ziemowit Thank you very mutch. It solved my problem. My solution:
Notice: |
@spencergibb Can we set a default value? This is an example project that reproduce the problem of PrematureCloseException: |
Please stop posting the same thing in multiple issues |
springboot2.1.6.RELEASE and Spring Cloud Greenwich.SR1
application.yml
spring:
application:
name: gateway-service
cloud:
gateway:
default-filters:
- StripPrefix=1
routes:
- id: provider_api_route
uri: lb://provider-service
predicates:
- Path=/web/**
discovery:
locator:
enabled: true
consul:
enabled: true
discovery:
instanceId: ${spring.application.name}:${vcap.application.instance_id:${spring.application.instance_id:${random.value}}}
#prefer-ip-address: true
retry:
initial-interval: 10
multiplier: 1
max-interval: 30000
max-attempts: 15
my pom.xml
`
org.springframework.boot
spring-boot-starter-parent
2.1.6.RELEASE
com.example
demo
0.0.1-SNAPSHOT
demo
Demo project for Spring Boot
The text was updated successfully, but these errors were encountered: